Commit 27796a7a167ae229680cf8bb8aee31409cbef92c
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/CNLiveApp
Conflicts: app/build.gradle app/libs/libcnlivelive.jar app/libs/libcnliveutil.jar app/src/main/AndroidManifest.xml app/src/main/jniLibs/arm64-v8a/libRongIMLib.so app/src/main/jniLibs/arm64-v8a/libksylive.so app/src/main/jniLibs/armeabi-v7a/libRongIMLib.so app/src/main/jniLibs/armeabi-v7a/libksylive.so app/src/main/jniLibs/armeabi/libRongIMLib.so app/src/main/jniLibs/armeabi/libksylive.so app/src/main/jniLibs/x86/libRongIMLib.so app/src/main/jniLibs/x86/libksylive.so app/src/main/res/values/strings.xml
Showing
76 changed files
with
5886 additions
and
5 deletions
app/build.gradle
| @@ -29,4 +29,6 @@ dependencies { | @@ -29,4 +29,6 @@ dependencies { | ||
| 29 | 29 | ||
| 30 | compile 'com.google.code.gson:gson:2.7' | 30 | compile 'com.google.code.gson:gson:2.7' |
| 31 | compile 'com.android.support.constraint:constraint-layout:1.0.2' | 31 | compile 'com.android.support.constraint:constraint-layout:1.0.2' |
| 32 | + compile 'com.github.bumptech.glide:glide:3.7.0' | ||
| 33 | + compile 'org.greenrobot:eventbus:3.0.0' | ||
| 32 | } | 34 | } |
app/src/main/AndroidManifest.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | package="com.cnlive.gundam"> | 3 | package="com.cnlive.gundam"> |
| 4 | + <uses-permission android:name="android.permission.GET_TASKS" /> | ||
| 5 | + <uses-permission android:name="android.permission.VIBRATE" /> | ||
| 6 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
| 7 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
| 8 | + <uses-permission android:name="android.permission.BLUETOOTH" /> | ||
| 9 | + <uses-permission android:name="android.permission.INTERNET" /> | ||
| 10 | + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
| 11 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
| 12 | + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
| 13 | + <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> | ||
| 14 | + <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | ||
| 15 | + <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> | ||
| 16 | + <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /> | ||
| 17 | + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||
| 18 | + <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | ||
| 19 | + <uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
| 4 | 20 | ||
| 5 | <uses-permission android:name="android.permission.GET_TASKS" /> | 21 | <uses-permission android:name="android.permission.GET_TASKS" /> |
| 6 | <uses-permission android:name="android.permission.VIBRATE" /> | 22 | <uses-permission android:name="android.permission.VIBRATE" /> |
| @@ -19,12 +35,13 @@ | @@ -19,12 +35,13 @@ | ||
| 19 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | 35 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
| 20 | 36 | ||
| 21 | <application | 37 | <application |
| 38 | + android:name=".main.application.CNLiveApplication" | ||
| 22 | android:allowBackup="true" | 39 | android:allowBackup="true" |
| 23 | android:icon="@mipmap/ic_launcher" | 40 | android:icon="@mipmap/ic_launcher" |
| 24 | android:label="@string/app_name" | 41 | android:label="@string/app_name" |
| 25 | android:roundIcon="@mipmap/ic_launcher_round" | 42 | android:roundIcon="@mipmap/ic_launcher_round" |
| 26 | android:supportsRtl="true" | 43 | android:supportsRtl="true" |
| 27 | - android:theme="@style/AppTheme"> | 44 | + android:theme="@style/Theme.AppCompat.Light.NoActionBar"> |
| 28 | <activity android:name=".main.ui.activity.MainActivity"> | 45 | <activity android:name=".main.ui.activity.MainActivity"> |
| 29 | <intent-filter> | 46 | <intent-filter> |
| 30 | <action android:name="android.intent.action.MAIN" /> | 47 | <action android:name="android.intent.action.MAIN" /> |
| @@ -33,6 +50,20 @@ | @@ -33,6 +50,20 @@ | ||
| 33 | </intent-filter> | 50 | </intent-filter> |
| 34 | </activity> | 51 | </activity> |
| 35 | 52 | ||
| 53 | + <activity | ||
| 54 | + android:name=".video.activity.PlayerActivity" | ||
| 55 | + android:configChanges="keyboardHidden|screenSize|orientation" | ||
| 56 | + android:launchMode="singleTop" | ||
| 57 | + android:screenOrientation="portrait" | ||
| 58 | + android:windowSoftInputMode="adjustResize" /> | ||
| 59 | + | ||
| 60 | + <receiver | ||
| 61 | + android:name=".video.utils.NetworkChangeReceive"> | ||
| 62 | + <intent-filter> | ||
| 63 | + <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> | ||
| 64 | + </intent-filter> | ||
| 65 | + </receiver> | ||
| 66 | + | ||
| 36 | 67 | ||
| 37 | <activity | 68 | <activity |
| 38 | android:name=".stream.ui.activity.StreamActivity" | 69 | android:name=".stream.ui.activity.StreamActivity" |
app/src/main/java/com/cnlive/gundam/main/application/CNLiveApplication.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.application; | ||
| 2 | + | ||
| 3 | +import android.app.Application; | ||
| 4 | + | ||
| 5 | +import com.cnlive.libs.util.Config; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Created by gujun on 2017/6/27. | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | +public class CNLiveApplication extends Application { | ||
| 12 | + | ||
| 13 | + @Override | ||
| 14 | + public void onCreate() { | ||
| 15 | + super.onCreate(); | ||
| 16 | + Config.init(getApplicationContext(), "60_j4fc7dsm83", "4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9", true); | ||
| 17 | + } | ||
| 18 | +} |
app/src/main/java/com/cnlive/gundam/main/model/ActiveInfo.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import java.io.Serializable; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * Created by Lynn on 5/25/2017. | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +public class ActiveInfo implements Serializable { | ||
| 11 | + private int totalCount; | ||
| 12 | + private int nextCursor; | ||
| 13 | + private int preCursor; | ||
| 14 | + private String activityId; | ||
| 15 | + private String activityName; | ||
| 16 | + private int activityStatus; | ||
| 17 | + private int isHorizontalScreen; | ||
| 18 | + private String channelId; | ||
| 19 | + private String createTime; | ||
| 20 | + private String startTime; | ||
| 21 | + private String endTime; | ||
| 22 | + private String coverImgUrl; | ||
| 23 | + private String activityCategory; | ||
| 24 | + private Object extensions; | ||
| 25 | + private String rates; | ||
| 26 | + | ||
| 27 | + public ActiveInfo() { | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public ActiveInfo(int totalCount, int nextCursor, int preCursor, String activityId, String activityName, int activityStatus, int isHorizontalScreen, String channelId, String createTime, String startTime, String endTime, String coverImgUrl, String activityCategory, Object extensions, String rates) { | ||
| 31 | + this.totalCount = totalCount; | ||
| 32 | + this.nextCursor = nextCursor; | ||
| 33 | + this.preCursor = preCursor; | ||
| 34 | + this.activityId = activityId; | ||
| 35 | + this.activityName = activityName; | ||
| 36 | + this.activityStatus = activityStatus; | ||
| 37 | + this.isHorizontalScreen = isHorizontalScreen; | ||
| 38 | + this.channelId = channelId; | ||
| 39 | + this.createTime = createTime; | ||
| 40 | + this.startTime = startTime; | ||
| 41 | + this.endTime = endTime; | ||
| 42 | + this.coverImgUrl = coverImgUrl; | ||
| 43 | + this.activityCategory = activityCategory; | ||
| 44 | + this.extensions = extensions; | ||
| 45 | + this.rates = rates; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public int getTotalCount() { | ||
| 49 | + return totalCount; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setTotalCount(int totalCount) { | ||
| 53 | + this.totalCount = totalCount; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public int getNextCursor() { | ||
| 57 | + return nextCursor; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setNextCursor(int nextCursor) { | ||
| 61 | + this.nextCursor = nextCursor; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public int getPreCursor() { | ||
| 65 | + return preCursor; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void setPreCursor(int preCursor) { | ||
| 69 | + this.preCursor = preCursor; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public String getActivityId() { | ||
| 73 | + return activityId; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setActivityId(String activityId) { | ||
| 77 | + this.activityId = activityId; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public String getActivityName() { | ||
| 81 | + return activityName; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public void setActivityName(String activityName) { | ||
| 85 | + this.activityName = activityName; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public int getActivityStatus() { | ||
| 89 | + return activityStatus; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public void setActivityStatus(int activityStatus) { | ||
| 93 | + this.activityStatus = activityStatus; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public int getIsHorizontalScreen() { | ||
| 97 | + return isHorizontalScreen; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public void setIsHorizontalScreen(int isHorizontalScreen) { | ||
| 101 | + this.isHorizontalScreen = isHorizontalScreen; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public String getChannelId() { | ||
| 105 | + return channelId; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public void setChannelId(String channelId) { | ||
| 109 | + this.channelId = channelId; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public String getCreateTime() { | ||
| 113 | + return createTime; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public void setCreateTime(String createTime) { | ||
| 117 | + this.createTime = createTime; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public String getStartTime() { | ||
| 121 | + return startTime; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public void setStartTime(String startTime) { | ||
| 125 | + this.startTime = startTime; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public String getEndTime() { | ||
| 129 | + return endTime; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public void setEndTime(String endTime) { | ||
| 133 | + this.endTime = endTime; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public String getCoverImgUrl() { | ||
| 137 | + return coverImgUrl; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public void setCoverImgUrl(String coverImgUrl) { | ||
| 141 | + this.coverImgUrl = coverImgUrl; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + public String getActivityCategory() { | ||
| 145 | + return activityCategory; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + public void setActivityCategory(String activityCategory) { | ||
| 149 | + this.activityCategory = activityCategory; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + public Object getExtensions() { | ||
| 153 | + return extensions; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + public void setExtensions(Object extensions) { | ||
| 157 | + this.extensions = extensions; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public String getRates() { | ||
| 161 | + return rates; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + public void setRates(String rates) { | ||
| 165 | + this.rates = rates; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + @Override | ||
| 169 | + public String toString() { | ||
| 170 | + return "ActiveInfo{" + | ||
| 171 | + "totalCount=" + totalCount + | ||
| 172 | + ", nextCursor=" + nextCursor + | ||
| 173 | + ", preCursor=" + preCursor + | ||
| 174 | + ", activityId='" + activityId + '\'' + | ||
| 175 | + ", activityName='" + activityName + '\'' + | ||
| 176 | + ", activityStatus=" + activityStatus + | ||
| 177 | + ", isHorizontalScreen=" + isHorizontalScreen + | ||
| 178 | + ", channelId='" + channelId + '\'' + | ||
| 179 | + ", createTime='" + createTime + '\'' + | ||
| 180 | + ", startTime='" + startTime + '\'' + | ||
| 181 | + ", endTime='" + endTime + '\'' + | ||
| 182 | + ", coverImgUrl='" + coverImgUrl + '\'' + | ||
| 183 | + ", activityCategory='" + activityCategory + '\'' + | ||
| 184 | + ", extensions='" + extensions + '\'' + | ||
| 185 | + ", rates='" + rates + '\'' + | ||
| 186 | + '}'; | ||
| 187 | + } | ||
| 188 | +} |
app/src/main/java/com/cnlive/gundam/main/model/ActiveListModel.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | ||
| 2 | + | ||
| 3 | +import java.io.Serializable; | ||
| 4 | +import java.util.List; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * Created by Lynn on 5/25/2017. | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +public class ActiveListModel extends ErrorMessage implements Serializable { | ||
| 11 | + | ||
| 12 | + private DataModel data; | ||
| 13 | + | ||
| 14 | + public ActiveListModel() { | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public ActiveListModel(DataModel data) { | ||
| 18 | + this.data = data; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public DataModel getData() { | ||
| 22 | + return data; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void setData(DataModel data) { | ||
| 26 | + this.data = data; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public class DataModel implements Serializable { | ||
| 30 | + private int totalCount; | ||
| 31 | + private int nextCursor; | ||
| 32 | + private List<ActiveInfo> activityList; | ||
| 33 | + private int preCursor; | ||
| 34 | + | ||
| 35 | + public DataModel() { | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public int getTotalCount() { | ||
| 39 | + return totalCount; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public void setTotalCount(int totalCount) { | ||
| 43 | + this.totalCount = totalCount; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public int getNextCursor() { | ||
| 47 | + return nextCursor; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public void setNextCursor(int nextCursor) { | ||
| 51 | + this.nextCursor = nextCursor; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public List<ActiveInfo> getActivityList() { | ||
| 55 | + return activityList; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void setActivityList(List<ActiveInfo> activityList) { | ||
| 59 | + this.activityList = activityList; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public int getPreCursor() { | ||
| 63 | + return preCursor; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public void setPreCursor(int preCursor) { | ||
| 67 | + this.preCursor = preCursor; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public String toString() { | ||
| 72 | + return "DataModel{" + | ||
| 73 | + "totalCount=" + totalCount + | ||
| 74 | + ", nextCursor=" + nextCursor + | ||
| 75 | + ", activityList=" + activityList + | ||
| 76 | + ", preCursor=" + preCursor + | ||
| 77 | + '}'; | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public String toString() { | ||
| 83 | + return "ActiveListModel{" + | ||
| 84 | + "data=" + data + | ||
| 85 | + '}'; | ||
| 86 | + } | ||
| 87 | +} |
app/src/main/java/com/cnlive/gundam/main/model/BaseInfo.java
0 → 100644
app/src/main/java/com/cnlive/gundam/main/model/ErrorMessage.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by xiansong on 2017/5/26. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +public class ErrorMessage implements BaseInfo { | ||
| 8 | + | ||
| 9 | + private String errorCode = "0"; | ||
| 10 | + private String errorMessage = ""; | ||
| 11 | + | ||
| 12 | + public void setErrorCode(String errorCode) { | ||
| 13 | + this.errorCode = errorCode; | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + @Override | ||
| 17 | + public String getCode() { | ||
| 18 | + return errorCode; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public void setErrorMessage(String errorMessage) { | ||
| 22 | + this.errorMessage = errorMessage; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String getMessage() { | ||
| 27 | + return errorMessage; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | +} |
app/src/main/java/com/cnlive/gundam/main/model/VideoListProgram.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import java.io.Serializable; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * Created by gujun on 2017/5/23. | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +public class VideoListProgram implements Serializable { | ||
| 11 | + //点播的id | ||
| 12 | + private String vId; | ||
| 13 | + //直播的id | ||
| 14 | + private String channelId; | ||
| 15 | + private String title; | ||
| 16 | + private String subTitle; | ||
| 17 | + private String img; | ||
| 18 | + //直播使用 | ||
| 19 | + private String docID; | ||
| 20 | + private String rates; | ||
| 21 | + private String type; | ||
| 22 | + | ||
| 23 | + public VideoListProgram() { | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public VideoListProgram(String vId, String title, String img, String subTitle, String rates, String type) { | ||
| 27 | + this.vId = vId; | ||
| 28 | + this.title = title; | ||
| 29 | + this.subTitle = subTitle; | ||
| 30 | + this.img = img; | ||
| 31 | + this.rates = rates; | ||
| 32 | + this.type = type; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public VideoListProgram(String channelId, String title, String img, String docID, String type) { | ||
| 36 | + this.channelId = channelId; | ||
| 37 | + this.title = title; | ||
| 38 | + this.img = img; | ||
| 39 | + this.docID = docID; | ||
| 40 | + this.type = type; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getvId() { | ||
| 44 | + return vId; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setvId(String vId) { | ||
| 48 | + this.vId = vId; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public String getChannelId() { | ||
| 52 | + return channelId; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void setChannelId(String channelId) { | ||
| 56 | + this.channelId = channelId; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public String getSubTitle() { | ||
| 60 | + return subTitle; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public void setSubTitle(String subTitle) { | ||
| 64 | + this.subTitle = subTitle; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public String getTitle() { | ||
| 68 | + return title; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public void setTitle(String title) { | ||
| 72 | + this.title = title; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public String getImg() { | ||
| 76 | + return img; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void setImg(String img) { | ||
| 80 | + this.img = img; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public String getDocID() { | ||
| 84 | + return docID; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public void setDocID(String docID) { | ||
| 88 | + this.docID = docID; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public String getRates() { | ||
| 92 | + return rates; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public void setRates(String rates) { | ||
| 96 | + this.rates = rates; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public String getType() { | ||
| 100 | + return type; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public void setType(String type) { | ||
| 104 | + this.type = type; | ||
| 105 | + } | ||
| 106 | +} |
app/src/main/java/com/cnlive/gundam/main/ui/activity/MainActivity.java
| @@ -30,9 +30,9 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | @@ -30,9 +30,9 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | ||
| 30 | binding.setOnSetCurrentTabListener(this); | 30 | binding.setOnSetCurrentTabListener(this); |
| 31 | binding.setTabItemInfoList(Arrays.asList( | 31 | binding.setTabItemInfoList(Arrays.asList( |
| 32 | FragmentTabHost.newTab("home", R.layout.indicator_main_home, HomeFragment.class), | 32 | FragmentTabHost.newTab("home", R.layout.indicator_main_home, HomeFragment.class), |
| 33 | - FragmentTabHost.newTab("media", R.layout.indicator_main_live_tv, UGCListFragment.class), | 33 | + FragmentTabHost.newTab("media", R.layout.indicator_main_live_tv, LiveFragment.class), |
| 34 | FragmentTabHost.newTab("stream", R.layout.indicator_main_stream, null), | 34 | FragmentTabHost.newTab("stream", R.layout.indicator_main_stream, null), |
| 35 | - FragmentTabHost.newTab("live", R.layout.indicator_main_live, LiveFragment.class), | 35 | + FragmentTabHost.newTab("live", R.layout.indicator_main_live, UGCListFragment.class), |
| 36 | FragmentTabHost.newTab("config", R.layout.indicator_main_mine, ConfigFragment.class) | 36 | FragmentTabHost.newTab("config", R.layout.indicator_main_mine, ConfigFragment.class) |
| 37 | )); | 37 | )); |
| 38 | } | 38 | } |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/BaseRecyclerAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.adapter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.support.v7.widget.RecyclerView; | ||
| 5 | + | ||
| 6 | +import java.util.ArrayList; | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Created by vclub on 15/5/11. | ||
| 11 | + */ | ||
| 12 | +public abstract class BaseRecyclerAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | ||
| 13 | + | ||
| 14 | + protected List<T> mItems ; | ||
| 15 | + protected Context mContext; | ||
| 16 | + | ||
| 17 | + public BaseRecyclerAdapter(Context context){ | ||
| 18 | + this.mContext = context; | ||
| 19 | + mItems = new ArrayList<>(); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public List<T> getList() { | ||
| 23 | + return mItems; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public void addItem(T item) { | ||
| 27 | + if(item == null) return ; | ||
| 28 | + mItems.add(mItems.size(), item); | ||
| 29 | + notifyItemInserted(mItems.size()); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public void addItems(List<T> items){ | ||
| 33 | + if(items == null) return ; | ||
| 34 | + this.mItems.addAll(items); | ||
| 35 | + notifyDataSetChanged(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public boolean containsAll(List<T> items){ | ||
| 39 | + return mItems.containsAll(items); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public void updateItem(T tasks, int position) { | ||
| 43 | + if(tasks == null) return ; | ||
| 44 | + mItems.set(position, tasks); | ||
| 45 | + notifyItemChanged(position); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public void updateItems(List<T> items){ | ||
| 49 | + if(items == null) return; | ||
| 50 | + this.mItems.clear(); | ||
| 51 | + this.mItems.addAll(items); | ||
| 52 | + notifyDataSetChanged(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void removeItem(int index) { | ||
| 56 | + mItems.remove(index); | ||
| 57 | + notifyItemRemoved(index); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void removeAllItems(){ | ||
| 61 | + mItems.clear(); | ||
| 62 | + notifyDataSetChanged(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void getView(int position , RecyclerView.ViewHolder viewHolder, int type, T item){} | ||
| 66 | + | ||
| 67 | + public T getItem(int location) { | ||
| 68 | + return mItems.get(location); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public int getItemCount() { | ||
| 73 | + return mItems == null ? 0 : mItems.size(); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + | ||
| 77 | +} |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/DataBindingAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.adapter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.databinding.DataBindingUtil; | ||
| 5 | +import android.databinding.ViewDataBinding; | ||
| 6 | +import android.support.v7.widget.RecyclerView; | ||
| 7 | +import android.view.LayoutInflater; | ||
| 8 | +import android.view.View; | ||
| 9 | +import android.view.ViewGroup; | ||
| 10 | + | ||
| 11 | +import com.cnlive.gundam.BR; | ||
| 12 | +import com.cnlive.gundam.main.ui.adapter.holder.DataBindingViewHolder; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * Created by gujun on 2017/5/23. | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +public class DataBindingAdapter<T> extends BaseRecyclerAdapter<T> { | ||
| 19 | + private int layoutId; | ||
| 20 | + private int itemBRId; | ||
| 21 | + private int imageHeightBRId = -1; | ||
| 22 | + private int imageHeight; | ||
| 23 | + | ||
| 24 | + private OnAdapterViewClickListener<T> l; | ||
| 25 | + private OnAdapterViewLoadMoreListener loadMoreListener; | ||
| 26 | + | ||
| 27 | + public DataBindingAdapter(Context context, int layoutId, int itemBRId) { | ||
| 28 | + super(context); | ||
| 29 | + this.layoutId = layoutId; | ||
| 30 | + this.itemBRId = itemBRId; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public DataBindingAdapter(Context context, int layoutId, int itemBRId, int imageHeightBRId, int imageHeight) { | ||
| 34 | + super(context); | ||
| 35 | + this.layoutId = layoutId; | ||
| 36 | + this.itemBRId = itemBRId; | ||
| 37 | + this.imageHeightBRId = imageHeightBRId; | ||
| 38 | + this.imageHeight = imageHeight; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setOnViewClickListener(OnAdapterViewClickListener listener) { | ||
| 42 | + l = listener; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public void setOnLoadMoreListener(OnAdapterViewLoadMoreListener listener) { | ||
| 46 | + loadMoreListener = listener; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
| 51 | + ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), layoutId, parent, false); | ||
| 52 | + DataBindingViewHolder viewHolder = new DataBindingViewHolder(binding.getRoot()); | ||
| 53 | + viewHolder.setBinding(binding); | ||
| 54 | + return viewHolder; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | ||
| 59 | + DataBindingViewHolder videoListViewHolder = (DataBindingViewHolder) holder; | ||
| 60 | + videoListViewHolder.getBinding().setVariable(itemBRId, getItem(position)); | ||
| 61 | + if (l != null) | ||
| 62 | + videoListViewHolder.getBinding().setVariable(BR.viewClickListner, l); | ||
| 63 | + if (imageHeightBRId != -1) | ||
| 64 | + videoListViewHolder.getBinding().setVariable(imageHeightBRId, imageHeight); | ||
| 65 | + videoListViewHolder.getBinding().executePendingBindings(); | ||
| 66 | + if (loadMoreListener != null && position == getList().size() - 1) { | ||
| 67 | + loadMoreListener.onLoadMore(); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public interface OnAdapterViewClickListener<T> { | ||
| 72 | + void onViewClick(View v, T program); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public interface OnAdapterViewLoadMoreListener { | ||
| 76 | + void onLoadMore(); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | +} |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/holder/DataBindingViewHolder.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.adapter.holder; | ||
| 2 | + | ||
| 3 | +import android.databinding.ViewDataBinding; | ||
| 4 | +import android.support.v7.widget.RecyclerView; | ||
| 5 | +import android.view.View; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Created by gujun on 2017/5/23. | ||
| 9 | + * DataBinding公用的holer | ||
| 10 | + */ | ||
| 11 | + | ||
| 12 | +public class DataBindingViewHolder extends RecyclerView.ViewHolder { | ||
| 13 | + | ||
| 14 | + private ViewDataBinding binding; | ||
| 15 | + | ||
| 16 | + public DataBindingViewHolder(View itemView) { | ||
| 17 | + super(itemView); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public void setBinding(ViewDataBinding binding) { | ||
| 21 | + this.binding = binding; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public ViewDataBinding getBinding() { | ||
| 25 | + return binding; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | +} |
app/src/main/java/com/cnlive/gundam/main/ui/fragment/LiveFragment.java
| 1 | package com.cnlive.gundam.main.ui.fragment; | 1 | package com.cnlive.gundam.main.ui.fragment; |
| 2 | 2 | ||
| 3 | +import android.databinding.DataBindingUtil; | ||
| 4 | +import android.os.Bundle; | ||
| 5 | +import android.support.annotation.Nullable; | ||
| 3 | import android.support.v4.app.Fragment; | 6 | import android.support.v4.app.Fragment; |
| 7 | +import android.support.v7.widget.LinearLayoutManager; | ||
| 8 | +import android.view.LayoutInflater; | ||
| 9 | +import android.view.View; | ||
| 10 | +import android.view.ViewGroup; | ||
| 11 | + | ||
| 12 | +import com.cnlive.gundam.BR; | ||
| 13 | +import com.cnlive.gundam.R; | ||
| 14 | +import com.cnlive.gundam.databinding.FragmentLiveBinding; | ||
| 15 | +import com.cnlive.gundam.main.model.VideoListProgram; | ||
| 16 | +import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter; | ||
| 17 | +import com.cnlive.gundam.main.utils.ActivityJumpUtil; | ||
| 18 | + | ||
| 19 | +import java.util.ArrayList; | ||
| 20 | +import java.util.List; | ||
| 4 | 21 | ||
| 5 | /** | 22 | /** |
| 6 | * Created by xiansong on 2017/6/27. | 23 | * Created by xiansong on 2017/6/27. |
| 7 | */ | 24 | */ |
| 8 | 25 | ||
| 9 | -public class LiveFragment extends Fragment { | 26 | +public class LiveFragment extends Fragment implements DataBindingAdapter.OnAdapterViewClickListener<VideoListProgram> { |
| 27 | + | ||
| 28 | + private FragmentLiveBinding binding; | ||
| 29 | + | ||
| 30 | + private List<VideoListProgram> programs; | ||
| 31 | + | ||
| 32 | + private DataBindingAdapter adapter; | ||
| 33 | + | ||
| 34 | + @Nullable | ||
| 35 | + @Override | ||
| 36 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
| 37 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_live, container, false); | ||
| 38 | + return binding.getRoot(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 43 | + super.onViewCreated(view, savedInstanceState); | ||
| 44 | + initData(); | ||
| 45 | + binding.setListAdapter(adapter = new DataBindingAdapter(getActivity(), R.layout.layout_item_video_list, BR.program)); | ||
| 46 | + binding.setLayoutManager(new LinearLayoutManager(getActivity())); | ||
| 47 | + adapter.updateItems(programs); | ||
| 48 | + adapter.setOnViewClickListener(this); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + private void initData() { | ||
| 52 | + programs = new ArrayList<>(); | ||
| 53 | + programs.add(new VideoListProgram("liveshow", "LiveShow", "http://yweb0.cnliveimg.com/cnlive/public/150417133551285_693.png", "408481", "live")); | ||
| 54 | + programs.add(new VideoListProgram("news", "快新闻", "http://yweb1.cnliveimg.com/img/cnlive/160121113653827_867.png", "85697", "live")); | ||
| 55 | + programs.add(new VideoListProgram("eyule", "e娱乐", "http://yweb2.cnliveimg.com/img/cnlive/160121113659992_585.png", "408480", "live")); | ||
| 56 | + programs.add(new VideoListProgram("chaotiyu", "潮体育", "http://yweb3.cnliveimg.com/img/cnlive/160121113706887_696.png", "285698", "live")); | ||
| 57 | + programs.add(new VideoListProgram("xuanhanyu", "炫韩娱", "http://yweb0.cnliveimg.com/cnlive/public/150417133341123_878.png", "408487", "live")); | ||
| 58 | + programs.add(new VideoListProgram("inyuetai", "in乐台", "http://yweb1.cnliveimg.com/cnlive/public/150417144750615_185.png", "285696", "live")); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public void onViewClick(View v, VideoListProgram program) { | ||
| 63 | + if (v.getId() == R.id.itemLayout) { | ||
| 64 | + ActivityJumpUtil.jumpByProgramType(getActivity(),program); | ||
| 65 | + } | ||
| 66 | + } | ||
| 10 | } | 67 | } |
app/src/main/java/com/cnlive/gundam/main/ui/fragment/UGCListFragment.java
| 1 | package com.cnlive.gundam.main.ui.fragment; | 1 | package com.cnlive.gundam.main.ui.fragment; |
| 2 | 2 | ||
| 3 | +import android.databinding.DataBindingUtil; | ||
| 4 | +import android.os.Bundle; | ||
| 5 | +import android.support.annotation.Nullable; | ||
| 3 | import android.support.v4.app.Fragment; | 6 | import android.support.v4.app.Fragment; |
| 7 | +import android.support.v4.widget.SwipeRefreshLayout; | ||
| 8 | +import android.support.v7.widget.LinearLayoutManager; | ||
| 9 | +import android.view.LayoutInflater; | ||
| 10 | +import android.view.View; | ||
| 11 | +import android.view.ViewGroup; | ||
| 12 | + | ||
| 13 | +import com.cnlive.gundam.BR; | ||
| 14 | +import com.cnlive.gundam.R; | ||
| 15 | +import com.cnlive.gundam.databinding.FragmentActiveListBinding; | ||
| 16 | +import com.cnlive.gundam.main.model.ActiveInfo; | ||
| 17 | +import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter; | ||
| 4 | 18 | ||
| 5 | /** | 19 | /** |
| 6 | * Created by xiansong on 2017/6/27. | 20 | * Created by xiansong on 2017/6/27. |
| 7 | */ | 21 | */ |
| 8 | 22 | ||
| 9 | -public class UGCListFragment extends Fragment { | 23 | +public class UGCListFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener, DataBindingAdapter.OnAdapterViewClickListener<ActiveInfo>, DataBindingAdapter.OnAdapterViewLoadMoreListener { |
| 24 | + | ||
| 25 | + private FragmentActiveListBinding binding; | ||
| 26 | + private DataBindingAdapter adapter; | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public void onCreate(Bundle savedInstanceState) { | ||
| 30 | + super.onCreate(savedInstanceState); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
| 35 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_active_list, container, false); | ||
| 36 | + binding.setListAdapter(adapter = new DataBindingAdapter(getActivity(), R.layout.layout_item_video_list, BR.program)); | ||
| 37 | + adapter.setOnViewClickListener(this); | ||
| 38 | + adapter.setOnLoadMoreListener(this); | ||
| 39 | + binding.setLayoutManager(new LinearLayoutManager(getActivity())); | ||
| 40 | + binding.contentView.setOnRefreshListener(this); | ||
| 41 | + return binding.getRoot(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 46 | + super.onViewCreated(view, savedInstanceState); | ||
| 47 | + loadData(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + private void loadData() { | ||
| 51 | + | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void onRefresh() { | ||
| 56 | + | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public void onViewClick(View v, ActiveInfo program) { | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public void onLoadMore() { | ||
| 66 | + | ||
| 67 | + } | ||
| 10 | } | 68 | } |
| 69 | + |
app/src/main/java/com/cnlive/gundam/main/utils/ActivityJumpUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.utils; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.Intent; | ||
| 6 | + | ||
| 7 | +import com.cnlive.gundam.main.model.VideoListProgram; | ||
| 8 | +import com.cnlive.gundam.video.activity.PlayerActivity; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by Lynn on 5/27/2017. | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | +public class ActivityJumpUtil { | ||
| 15 | + | ||
| 16 | +// //活动视频页面跳转 | ||
| 17 | +// public static void jumpByProgramType(final Context context, final VideoListPage.Program program) { | ||
| 18 | +// if (context == null || program == null) | ||
| 19 | +// return; | ||
| 20 | +//// intentByStatus(context, program); | ||
| 21 | +// ApiServiceUtil.getActivePlayInfo(context, program.getActivityId()).subscribe(new com.cnlive.granzon.data.network.network.Subscriber<ActivePlayInfo>() { | ||
| 22 | +// @Override | ||
| 23 | +// public void onCompleted(ActivePlayInfo data) { | ||
| 24 | +// program.setIsHorizontalScreen(data.getData().getIsHorizontalScreen()); | ||
| 25 | +// program.setActivityId(data.getData().getActivityId()); | ||
| 26 | +// program.setChannelId(data.getData().getChannelId()); | ||
| 27 | +// program.setRates(data.getData().getRates()); | ||
| 28 | +// program.setActivityName(data.getData().getActivityName()); | ||
| 29 | +// intentByStatus(context, program); | ||
| 30 | +// } | ||
| 31 | +// | ||
| 32 | +// @Override | ||
| 33 | +// public void onError(String code, String message) { | ||
| 34 | +// intentByStatus(context, program); | ||
| 35 | +// } | ||
| 36 | +// }); | ||
| 37 | +// | ||
| 38 | +// | ||
| 39 | +// } | ||
| 40 | +// | ||
| 41 | +// private static void intentByStatus(Context context, VideoListPage.Program program) { | ||
| 42 | +// switch (program.getActivityStatus()) { | ||
| 43 | +// case 0: | ||
| 44 | +// case 3: | ||
| 45 | +// case 4: | ||
| 46 | +// if (context instanceof Activity) { | ||
| 47 | +// Intent intentVod = new Intent(context, PlayerActivity.class); | ||
| 48 | +// VideoListProgram videoListProgram = VideoListProgram.toVideoListProgram(program, "ugcVod"); | ||
| 49 | +// intentVod.putExtra("program", videoListProgram); | ||
| 50 | +// intentVod.putExtra("screenDirect", program.getIsHorizontalScreen() + ""); | ||
| 51 | +// context.startActivity(intentVod); | ||
| 52 | +// } else { | ||
| 53 | +// Intent intentVod = new Intent(context, PlayerActivity.class); | ||
| 54 | +// VideoListProgram videoListProgram = VideoListProgram.toVideoListProgram(program, "ugcVod"); | ||
| 55 | +// intentVod.putExtra("program", videoListProgram); | ||
| 56 | +// intentVod.putExtra("screenDirect", program.getIsHorizontalScreen() + ""); | ||
| 57 | +// intentVod.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
| 58 | +// context.startActivity(intentVod); | ||
| 59 | +// } | ||
| 60 | +// break; | ||
| 61 | +// case -2: | ||
| 62 | +// case 1: | ||
| 63 | +// if (context instanceof Activity) { | ||
| 64 | +// Intent intentLive = new Intent(context, PlayerActivity.class); | ||
| 65 | +// VideoListProgram videoListProgram = VideoListProgram.toVideoListProgram(program, "ugcLive"); | ||
| 66 | +// intentLive.putExtra("program", videoListProgram); | ||
| 67 | +// intentLive.putExtra("screenDirect", program.getIsHorizontalScreen() + ""); | ||
| 68 | +// context.startActivity(intentLive); | ||
| 69 | +// } else { | ||
| 70 | +// Intent intentLive = new Intent(context, PlayerActivity.class); | ||
| 71 | +// VideoListProgram videoListProgram = VideoListProgram.toVideoListProgram(program, "ugcLive"); | ||
| 72 | +// intentLive.putExtra("program", videoListProgram); | ||
| 73 | +// intentLive.putExtra("screenDirect", program.getIsHorizontalScreen() + ""); | ||
| 74 | +// intentLive.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
| 75 | +// context.startActivity(intentLive); | ||
| 76 | +// } | ||
| 77 | +// break; | ||
| 78 | +// } | ||
| 79 | +// } | ||
| 80 | + | ||
| 81 | + //视频页面跳转 | ||
| 82 | + public static void jumpByProgramType(final Context context, final VideoListProgram program) { | ||
| 83 | + if (context == null || program == null) | ||
| 84 | + return; | ||
| 85 | + Intent intent = new Intent(context, PlayerActivity.class); | ||
| 86 | + intent.putExtra("program", program); | ||
| 87 | + context.startActivity(intent); | ||
| 88 | + } | ||
| 89 | +} |
app/src/main/java/com/cnlive/gundam/main/utils/BindingAdapterUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.utils; | ||
| 2 | + | ||
| 3 | +import android.databinding.BindingAdapter; | ||
| 4 | +import android.graphics.drawable.Drawable; | ||
| 5 | +import android.view.View; | ||
| 6 | +import android.view.ViewGroup; | ||
| 7 | +import android.widget.ImageView; | ||
| 8 | + | ||
| 9 | +import com.bumptech.glide.Glide; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Created by gujun on 2017/5/24. | ||
| 13 | + * 工具 | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +public class BindingAdapterUtil { | ||
| 17 | + | ||
| 18 | + //后面是自定义的属性名字app:imageUrl app:error | ||
| 19 | + @BindingAdapter({"imageUrl", "error"}) | ||
| 20 | + public static void loadImage(ImageView view, String url, Drawable error) { | ||
| 21 | + Glide.with(view.getContext()).load(url).error(error).into(view); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @BindingAdapter("android:layout_height") | ||
| 25 | + public static void setLayoutHeight(View view, int height) { | ||
| 26 | + ViewGroup.LayoutParams params = view.getLayoutParams(); | ||
| 27 | + params.height = height; | ||
| 28 | + view.setLayoutParams(params); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @BindingAdapter("android:layout_width") | ||
| 32 | + public static void setLayoutWidth(View view, int width) { | ||
| 33 | + ViewGroup.LayoutParams params = view.getLayoutParams(); | ||
| 34 | + params.width = width; | ||
| 35 | + view.setLayoutParams(params); | ||
| 36 | + } | ||
| 37 | +} |
app/src/main/java/com/cnlive/gundam/main/utils/SharedPreferencesHelper.java
0 → 100644
| 1 | + | ||
| 2 | +package com.cnlive.gundam.main.utils; | ||
| 3 | + | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.SharedPreferences; | ||
| 6 | + | ||
| 7 | +import java.util.Set; | ||
| 8 | + | ||
| 9 | +public class SharedPreferencesHelper { | ||
| 10 | + | ||
| 11 | + private static final String APP_NAME = "com.cnlive.granzon"; | ||
| 12 | + public static SharedPreferencesHelper instance; | ||
| 13 | + protected Context mContext; | ||
| 14 | + protected SharedPreferences sharedPreferences; | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + private SharedPreferencesHelper(Context context) { | ||
| 18 | + mContext = context; | ||
| 19 | + sharedPreferences = mContext.getSharedPreferences(APP_NAME, 0); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 线程安全调用 | ||
| 24 | + * | ||
| 25 | + * @param context | ||
| 26 | + * @return | ||
| 27 | + */ | ||
| 28 | + public static synchronized SharedPreferencesHelper getInstance(Context context) { | ||
| 29 | + if (null == instance) | ||
| 30 | + instance = new SharedPreferencesHelper(context.getApplicationContext()); | ||
| 31 | + return instance; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public String getValue(String key) { | ||
| 35 | + return sharedPreferences.getString(key, ""); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public Boolean getBoolValue(String key) { | ||
| 39 | + return sharedPreferences.getBoolean(key, false); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public Boolean getBoolean(String key, boolean defaultValue) { | ||
| 43 | + return sharedPreferences.getBoolean(key, defaultValue); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public Long getLong(String key){ | ||
| 47 | + return sharedPreferences.getLong(key,0); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public int getIntValue(String key) { | ||
| 51 | + return sharedPreferences.getInt(key, 0); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public int getIntValue(String key, int deft) { | ||
| 55 | + return sharedPreferences.getInt(key, deft); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void setValue(String key, Boolean value) { | ||
| 59 | + SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
| 60 | + editor.putBoolean(key, value); | ||
| 61 | + editor.apply(); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public void setValue(String key, String value) { | ||
| 65 | + SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
| 66 | + editor.putString(key, value); | ||
| 67 | + editor.apply(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public void setValue(String key, int value) { | ||
| 71 | + SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
| 72 | + editor.putInt(key, value); | ||
| 73 | + editor.apply(); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setValue(String key, long value) { | ||
| 77 | + SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
| 78 | + editor.putLong(key, value); | ||
| 79 | + editor.apply(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public void remove(String key) { | ||
| 83 | + SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
| 84 | + editor.remove(key); | ||
| 85 | + editor.apply(); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public void clear() { | ||
| 89 | + SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
| 90 | + editor.clear(); | ||
| 91 | + editor.apply(); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public Set<String> getSaveKeys() { | ||
| 95 | + return sharedPreferences.getAll().keySet(); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public boolean contains(String key){ | ||
| 99 | + return sharedPreferences.contains(key); | ||
| 100 | + } | ||
| 101 | +} |
app/src/main/java/com/cnlive/gundam/video/activity/PlayerActivity.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.activity; | ||
| 2 | + | ||
| 3 | +import android.content.Intent; | ||
| 4 | +import android.content.pm.ActivityInfo; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | +import android.support.annotation.Nullable; | ||
| 7 | +import android.support.v4.app.Fragment; | ||
| 8 | +import android.support.v7.app.AppCompatActivity; | ||
| 9 | +import android.widget.Toast; | ||
| 10 | + | ||
| 11 | +import com.cnlive.gundam.R; | ||
| 12 | +import com.cnlive.gundam.main.model.VideoListProgram; | ||
| 13 | +import com.cnlive.gundam.video.fragment.PlayerLiveFragment; | ||
| 14 | +import com.cnlive.gundam.video.fragment.PlayerUgcLiveFragment; | ||
| 15 | +import com.cnlive.gundam.video.fragment.PlayerUgcVodFragment; | ||
| 16 | +import com.cnlive.gundam.video.fragment.PlayerVodFragment; | ||
| 17 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Created by gujun on 2017/4/5. | ||
| 21 | + * screenDirect //0:竖向 1;横向 ugcLive ugcVod 播放页面用到了 | ||
| 22 | + */ | ||
| 23 | + | ||
| 24 | +public class PlayerActivity extends AppCompatActivity { | ||
| 25 | + private final String SCREEN_DIRECT_P = "0"; | ||
| 26 | + private final String SCREEN_DIRECT_L = "1"; | ||
| 27 | + | ||
| 28 | + private Fragment fragment; | ||
| 29 | + private VideoListProgram program; | ||
| 30 | + //默认横屏 | ||
| 31 | + private String screenDirect = SCREEN_DIRECT_L; | ||
| 32 | + private String screenDirectName = "screenDirect"; | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
| 36 | + super.onCreate(savedInstanceState); | ||
| 37 | + setContentView(R.layout.activity_player); | ||
| 38 | + addData(getIntent()); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + protected void onNewIntent(Intent intent) { | ||
| 43 | + super.onNewIntent(intent); | ||
| 44 | + addData(intent); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + private void addData(Intent intent) { | ||
| 48 | + program = (VideoListProgram) intent.getSerializableExtra("program"); | ||
| 49 | + if (program.getType() == null) return; | ||
| 50 | + switch (program.getType()) { | ||
| 51 | + case "live": | ||
| 52 | + fragment = PlayerLiveFragment.newInstance(program); | ||
| 53 | + break; | ||
| 54 | + case "program": | ||
| 55 | + fragment = PlayerVodFragment.newInstance(program); | ||
| 56 | + break; | ||
| 57 | + case "ugcLive": | ||
| 58 | + fragment = PlayerUgcLiveFragment.newInstance(program); | ||
| 59 | + break; | ||
| 60 | + case "ugcVod": | ||
| 61 | + fragment = PlayerUgcVodFragment.newInstance(program); | ||
| 62 | + break; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + if (fragment == null) { | ||
| 66 | + Toast.makeText(this, "no fragment", Toast.LENGTH_LONG).show(); | ||
| 67 | + finish(); | ||
| 68 | + return; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + if (fragment instanceof PlayerUgcLiveFragment || fragment instanceof PlayerUgcVodFragment) { | ||
| 72 | + if (intent.hasExtra(screenDirectName)) { | ||
| 73 | + screenDirect = intent.getStringExtra(screenDirectName); | ||
| 74 | + } | ||
| 75 | + if (SCREEN_DIRECT_P.equals(screenDirect)) { | ||
| 76 | + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
| 77 | + } else { | ||
| 78 | + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainer, fragment).commit(); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + public void onBackPressed() { | ||
| 87 | + if (!(PlayerUtils.isPortrait(this)) && (fragment instanceof PlayerLiveFragment || fragment instanceof PlayerVodFragment)) { | ||
| 88 | + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
| 89 | + } else { | ||
| 90 | + super.onBackPressed(); | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | +} |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerLiveFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.fragment; | ||
| 2 | + | ||
| 3 | +import android.content.pm.ActivityInfo; | ||
| 4 | +import android.content.res.Configuration; | ||
| 5 | +import android.databinding.DataBindingUtil; | ||
| 6 | +import android.os.Bundle; | ||
| 7 | +import android.support.annotation.Nullable; | ||
| 8 | +import android.support.v4.app.Fragment; | ||
| 9 | +import android.view.LayoutInflater; | ||
| 10 | +import android.view.View; | ||
| 11 | +import android.view.ViewGroup; | ||
| 12 | + | ||
| 13 | +import com.cnlive.gundam.R; | ||
| 14 | +import com.cnlive.gundam.databinding.FragmentPlayerLiveBinding; | ||
| 15 | +import com.cnlive.gundam.main.model.VideoListProgram; | ||
| 16 | +import com.cnlive.gundam.video.model.VideoModel; | ||
| 17 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 18 | +import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Created by gujun on 2017/6/27. | ||
| 22 | + */ | ||
| 23 | + | ||
| 24 | +public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerSensor.ScreenOrientationListener{ | ||
| 25 | + private FragmentPlayerLiveBinding binding; | ||
| 26 | + | ||
| 27 | + private VideoListProgram program; | ||
| 28 | + private PlayerAccelerometerSensor playerAccelerometerSensor; | ||
| 29 | + | ||
| 30 | + public static PlayerLiveFragment newInstance(VideoListProgram program) { | ||
| 31 | + | ||
| 32 | + Bundle args = new Bundle(); | ||
| 33 | + args.putSerializable("program", program); | ||
| 34 | + PlayerLiveFragment fragment = new PlayerLiveFragment(); | ||
| 35 | + fragment.setArguments(args); | ||
| 36 | + return fragment; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public void onCreate(Bundle savedInstanceState) { | ||
| 41 | + super.onCreate(savedInstanceState); | ||
| 42 | + playerAccelerometerSensor = new PlayerAccelerometerSensor(getActivity()); | ||
| 43 | + playerAccelerometerSensor.setScreenOrientationListener(this); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Nullable | ||
| 47 | + @Override | ||
| 48 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
| 49 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_live, container, false); | ||
| 50 | + return binding.getRoot(); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 55 | + super.onViewCreated(view, savedInstanceState); | ||
| 56 | + init(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + private void init() { | ||
| 60 | + program = (VideoListProgram) getArguments().getSerializable("program"); | ||
| 61 | + if(program == null) return; | ||
| 62 | + VideoModel model = new VideoModel(program.getTitle(), program.getChannelId(), program.getType(), program.getRates()); | ||
| 63 | + binding.videoView.setVideoInfo(model); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public void onConfigurationChanged(Configuration newConfig) { | ||
| 68 | + super.onConfigurationChanged(newConfig); | ||
| 69 | + boolean isPortrait = PlayerUtils.isPortrait(getActivity()); | ||
| 70 | + binding.videoView.onScreenChange(isPortrait); | ||
| 71 | + | ||
| 72 | + PlayerUtils.setStatusBarVisibility(getActivity(), isPortrait); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public void onResume() { | ||
| 77 | + super.onResume(); | ||
| 78 | + binding.videoView.onResume(); | ||
| 79 | + playerAccelerometerSensor.register(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public void onPause() { | ||
| 84 | + super.onPause(); | ||
| 85 | + binding.videoView.onPause(); | ||
| 86 | + playerAccelerometerSensor.unregister(); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @Override | ||
| 90 | + public void onDestroyView() { | ||
| 91 | + binding.videoView.onDestroy(); | ||
| 92 | + super.onDestroyView(); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @Override | ||
| 96 | + public void onOrientationChange(int orientation) { | ||
| 97 | + if (orientation == PlayerAccelerometerSensor.ORIENTATION_PORTRAIT) { | ||
| 98 | + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
| 99 | + } else if (orientation == PlayerAccelerometerSensor.ORIENTATION_LANDSCAPE) { | ||
| 100 | + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | ||
| 101 | + } else if (orientation == PlayerAccelerometerSensor.ORIENTATION_REVERSE_LANDSCAPE) { | ||
| 102 | + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | +} |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerUgcLiveFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.fragment; | ||
| 2 | + | ||
| 3 | +import android.content.res.Configuration; | ||
| 4 | +import android.databinding.DataBindingUtil; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | +import android.support.annotation.Nullable; | ||
| 7 | +import android.support.v4.app.Fragment; | ||
| 8 | +import android.view.LayoutInflater; | ||
| 9 | +import android.view.View; | ||
| 10 | +import android.view.ViewGroup; | ||
| 11 | + | ||
| 12 | +import com.cnlive.gundam.R; | ||
| 13 | +import com.cnlive.gundam.databinding.FragmentPlayerUgcVodBinding; | ||
| 14 | +import com.cnlive.gundam.main.model.VideoListProgram; | ||
| 15 | +import com.cnlive.gundam.video.model.VideoModel; | ||
| 16 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 17 | +import com.cnlive.gundam.video.view.VideoView; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Created by gujun on 2017/4/5. | ||
| 21 | + */ | ||
| 22 | + | ||
| 23 | +public class PlayerUgcLiveFragment extends Fragment { | ||
| 24 | + private FragmentPlayerUgcVodBinding binding; | ||
| 25 | + | ||
| 26 | + private VideoListProgram program; | ||
| 27 | + private String title; | ||
| 28 | + private String id; | ||
| 29 | + private String rates; | ||
| 30 | + | ||
| 31 | + public static PlayerUgcLiveFragment newInstance(VideoListProgram program) { | ||
| 32 | + | ||
| 33 | + Bundle args = new Bundle(); | ||
| 34 | + | ||
| 35 | + args.putSerializable("program", program); | ||
| 36 | + PlayerUgcLiveFragment fragment = new PlayerUgcLiveFragment(); | ||
| 37 | + fragment.setArguments(args); | ||
| 38 | + return fragment; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + private void initData() { | ||
| 42 | + program = (VideoListProgram) getArguments().getSerializable("program"); | ||
| 43 | + | ||
| 44 | + title = program.getTitle(); | ||
| 45 | + id = program.getChannelId(); | ||
| 46 | + rates = program.getRates(); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Nullable | ||
| 50 | + @Override | ||
| 51 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
| 52 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_ugc_live, container, false); | ||
| 53 | + initData(); | ||
| 54 | + return binding.getRoot(); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 59 | + super.onViewCreated(view, savedInstanceState); | ||
| 60 | + binding.videoView.setVideoInfo(new VideoModel(title, id, VideoView.TYPE_UGC_LIVE, rates)); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public void onConfigurationChanged(Configuration newConfig) { | ||
| 65 | + super.onConfigurationChanged(newConfig); | ||
| 66 | + boolean isPortrait = PlayerUtils.isPortrait(getActivity()); | ||
| 67 | + binding.videoView.onScreenChange(isPortrait); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public void onResume() { | ||
| 72 | + super.onResume(); | ||
| 73 | + binding.videoView.onResume(); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public void onPause() { | ||
| 78 | + super.onPause(); | ||
| 79 | + binding.videoView.onPause(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public void onDestroyView() { | ||
| 84 | + binding.videoView.onDestroy(); | ||
| 85 | + super.onDestroyView(); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | +} |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerUgcVodFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.fragment; | ||
| 2 | + | ||
| 3 | +import android.content.res.Configuration; | ||
| 4 | +import android.databinding.DataBindingUtil; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | +import android.support.annotation.Nullable; | ||
| 7 | +import android.support.v4.app.Fragment; | ||
| 8 | +import android.view.LayoutInflater; | ||
| 9 | +import android.view.View; | ||
| 10 | +import android.view.ViewGroup; | ||
| 11 | + | ||
| 12 | +import com.cnlive.gundam.R; | ||
| 13 | +import com.cnlive.gundam.databinding.FragmentPlayerUgcVodBinding; | ||
| 14 | +import com.cnlive.gundam.main.model.VideoListProgram; | ||
| 15 | +import com.cnlive.gundam.video.model.VideoModel; | ||
| 16 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 17 | +import com.cnlive.gundam.video.view.VideoView; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Created by gujun on 2017/4/6. | ||
| 21 | + */ | ||
| 22 | + | ||
| 23 | +public class PlayerUgcVodFragment extends Fragment{ | ||
| 24 | + private FragmentPlayerUgcVodBinding binding; | ||
| 25 | + | ||
| 26 | + private VideoListProgram program; | ||
| 27 | + private String id; | ||
| 28 | + private String rates; | ||
| 29 | + private String title; | ||
| 30 | + | ||
| 31 | + public static PlayerUgcVodFragment newInstance(VideoListProgram program) { | ||
| 32 | + | ||
| 33 | + Bundle args = new Bundle(); | ||
| 34 | + args.putSerializable("program",program); | ||
| 35 | + | ||
| 36 | + PlayerUgcVodFragment fragment = new PlayerUgcVodFragment(); | ||
| 37 | + fragment.setArguments(args); | ||
| 38 | + return fragment; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + private void initData() { | ||
| 42 | + program = (VideoListProgram) getArguments().getSerializable("program"); | ||
| 43 | + title = program.getTitle(); | ||
| 44 | + id = program.getvId(); | ||
| 45 | + rates = program.getRates(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Nullable | ||
| 49 | + @Override | ||
| 50 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
| 51 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_ugc_vod, container, false); | ||
| 52 | + initData(); | ||
| 53 | + return binding.getRoot(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 58 | + super.onViewCreated(view, savedInstanceState); | ||
| 59 | + binding.videoView.setVideoInfo(new VideoModel(title, id, VideoView.TYPE_UGC_VOD, rates)); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void onConfigurationChanged(Configuration newConfig) { | ||
| 64 | + super.onConfigurationChanged(newConfig); | ||
| 65 | + boolean isPortrait = PlayerUtils.isPortrait(getActivity()); | ||
| 66 | + binding.videoView.onScreenChange(isPortrait); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public void onResume() { | ||
| 71 | + super.onResume(); | ||
| 72 | + binding.videoView.onResume(); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public void onPause() { | ||
| 77 | + super.onPause(); | ||
| 78 | + binding.videoView.onPause(); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public void onDestroyView() { | ||
| 83 | + binding.videoView.onDestroy(); | ||
| 84 | + super.onDestroyView(); | ||
| 85 | + } | ||
| 86 | +} |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerVodFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.fragment; | ||
| 2 | + | ||
| 3 | +import android.content.pm.ActivityInfo; | ||
| 4 | +import android.content.res.Configuration; | ||
| 5 | +import android.databinding.DataBindingUtil; | ||
| 6 | +import android.os.Bundle; | ||
| 7 | +import android.support.annotation.Nullable; | ||
| 8 | +import android.support.v4.app.Fragment; | ||
| 9 | +import android.view.LayoutInflater; | ||
| 10 | +import android.view.View; | ||
| 11 | +import android.view.ViewGroup; | ||
| 12 | + | ||
| 13 | +import com.cnlive.gundam.R; | ||
| 14 | +import com.cnlive.gundam.databinding.FragmentPlayerVodBinding; | ||
| 15 | +import com.cnlive.gundam.main.model.VideoListProgram; | ||
| 16 | +import com.cnlive.gundam.video.model.VideoModel; | ||
| 17 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 18 | +import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Created by gujun on 2017/4/6. | ||
| 22 | + */ | ||
| 23 | + | ||
| 24 | +public class PlayerVodFragment extends Fragment implements PlayerAccelerometerSensor.ScreenOrientationListener { | ||
| 25 | + private VideoListProgram program; | ||
| 26 | + private FragmentPlayerVodBinding binding; | ||
| 27 | + private PlayerAccelerometerSensor playerAccelerometerSensor; | ||
| 28 | + | ||
| 29 | + public static PlayerVodFragment newInstance(VideoListProgram program) { | ||
| 30 | + Bundle args = new Bundle(); | ||
| 31 | + args.putSerializable("program", program); | ||
| 32 | + PlayerVodFragment fragment = new PlayerVodFragment(); | ||
| 33 | + fragment.setArguments(args); | ||
| 34 | + return fragment; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void onCreate(Bundle savedInstanceState) { | ||
| 39 | + super.onCreate(savedInstanceState); | ||
| 40 | + playerAccelerometerSensor = new PlayerAccelerometerSensor(getActivity()); | ||
| 41 | + playerAccelerometerSensor.setScreenOrientationListener(this); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Nullable | ||
| 45 | + @Override | ||
| 46 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
| 47 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_vod, container, false); | ||
| 48 | + return binding.getRoot(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 53 | + super.onViewCreated(view, savedInstanceState); | ||
| 54 | + init(); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + private void init() { | ||
| 58 | + program = (VideoListProgram) getArguments().getSerializable("program"); | ||
| 59 | + if (program == null) return; | ||
| 60 | + VideoModel videoModel = new VideoModel(program.getTitle(), program.getvId(), program.getType(), program.getRates()); | ||
| 61 | + binding.videoView.setVideoInfo(videoModel); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public void onConfigurationChanged(Configuration newConfig) { | ||
| 66 | + super.onConfigurationChanged(newConfig); | ||
| 67 | + boolean isPortrait = PlayerUtils.isPortrait(getActivity()); | ||
| 68 | + binding.videoView.onScreenChange(isPortrait); | ||
| 69 | + | ||
| 70 | + PlayerUtils.setStatusBarVisibility(getActivity(), isPortrait); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Override | ||
| 74 | + public void onResume() { | ||
| 75 | + super.onResume(); | ||
| 76 | + binding.videoView.onResume(); | ||
| 77 | + playerAccelerometerSensor.register(); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public void onPause() { | ||
| 82 | + super.onPause(); | ||
| 83 | + binding.videoView.onPause(); | ||
| 84 | + playerAccelerometerSensor.unregister(); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Override | ||
| 88 | + public void onDestroyView() { | ||
| 89 | + binding.videoView.onDestroy(); | ||
| 90 | + super.onDestroyView(); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + @Override | ||
| 95 | + public void onOrientationChange(int orientation) { | ||
| 96 | + if (orientation == PlayerAccelerometerSensor.ORIENTATION_PORTRAIT) { | ||
| 97 | + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
| 98 | + } else if (orientation == PlayerAccelerometerSensor.ORIENTATION_LANDSCAPE) { | ||
| 99 | + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | ||
| 100 | + } else if (orientation == PlayerAccelerometerSensor.ORIENTATION_REVERSE_LANDSCAPE) { | ||
| 101 | + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | +} |
app/src/main/java/com/cnlive/gundam/video/model/DataSource.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.model; | ||
| 2 | + | ||
| 3 | +import com.cnlive.libs.video.video.base.IDataSource; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Created by gujun on 2017/5/22. | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +public class DataSource implements IDataSource { | ||
| 10 | + private String id; | ||
| 11 | + private String type; | ||
| 12 | + private String rate; | ||
| 13 | + | ||
| 14 | + public DataSource(String id, String type, String rate) { | ||
| 15 | + this.id = id; | ||
| 16 | + this.type = type; | ||
| 17 | + this.rate = rate; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public void setRate(String rate) { | ||
| 21 | + this.rate = rate; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public String getDataSourceId() { | ||
| 26 | + return id; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public String getDataSourceType() { | ||
| 31 | + return type; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public String getDataSourceRate() { | ||
| 36 | + return rate; | ||
| 37 | + } | ||
| 38 | +} |
app/src/main/java/com/cnlive/gundam/video/model/NetStatusEvent.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.model; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by gujun on 2017/6/23. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +public class NetStatusEvent { | ||
| 8 | + | ||
| 9 | + public static final int NET_DISCONNECT = 0x1001; | ||
| 10 | + public static final int NET_MOBILE = 0x1002; | ||
| 11 | + public static final int NET_WIFI = 0x1003; | ||
| 12 | + | ||
| 13 | + private int netStatus; | ||
| 14 | + | ||
| 15 | + public NetStatusEvent(int status) { | ||
| 16 | + netStatus = status; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public int getNetStatus() { | ||
| 20 | + return netStatus; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setNetStatus(int netStatus) { | ||
| 24 | + this.netStatus = netStatus; | ||
| 25 | + } | ||
| 26 | +} |
app/src/main/java/com/cnlive/gundam/video/model/VideoModel.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.model; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by gujun on 2017/4/28. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +public class VideoModel { | ||
| 8 | + | ||
| 9 | + private String title; | ||
| 10 | + private String id; | ||
| 11 | + private String type; | ||
| 12 | + private String rates; | ||
| 13 | + | ||
| 14 | + public VideoModel(String title, String id, String type, String rates) { | ||
| 15 | + this.title = title; | ||
| 16 | + this.id = id; | ||
| 17 | + this.type = type; | ||
| 18 | + this.rates = rates; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public String getTitle() { | ||
| 22 | + return title; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void setTitle(String title) { | ||
| 26 | + this.title = title; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public String getId() { | ||
| 30 | + return id; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public void setId(String id) { | ||
| 34 | + this.id = id; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public String getType() { | ||
| 38 | + return type; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setType(String type) { | ||
| 42 | + this.type = type; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public String getRates() { | ||
| 46 | + return rates; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setRates(String rates) { | ||
| 50 | + this.rates = rates; | ||
| 51 | + } | ||
| 52 | +} |
app/src/main/java/com/cnlive/gundam/video/test.java
0 → 100644
app/src/main/java/com/cnlive/gundam/video/utils/DensityUtils.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.utils; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.support.annotation.NonNull; | ||
| 5 | +import android.util.TypedValue; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 常用单位转换的辅助类 | ||
| 9 | + */ | ||
| 10 | +public class DensityUtils { | ||
| 11 | + | ||
| 12 | + private DensityUtils() { | ||
| 13 | + /** cannot be instantiated **/ | ||
| 14 | + throw new UnsupportedOperationException("cannot be instantiated"); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * dp转px | ||
| 19 | + * | ||
| 20 | + * @param context | ||
| 21 | + * @param dpVal | ||
| 22 | + * @return | ||
| 23 | + */ | ||
| 24 | + public static int dp2px(@NonNull Context context, float dpVal) { | ||
| 25 | + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, | ||
| 26 | + dpVal, context.getResources().getDisplayMetrics()); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * sp转px | ||
| 31 | + * | ||
| 32 | + * @param context | ||
| 33 | + * @param spVal | ||
| 34 | + * @return | ||
| 35 | + */ | ||
| 36 | + public static int sp2px(@NonNull Context context, float spVal) { | ||
| 37 | + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, | ||
| 38 | + spVal, context.getResources().getDisplayMetrics()); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * px转dp | ||
| 43 | + * | ||
| 44 | + * @param context | ||
| 45 | + * @param pxVal | ||
| 46 | + * @return | ||
| 47 | + */ | ||
| 48 | + public static float px2dp(@NonNull Context context, float pxVal) { | ||
| 49 | + final float scale = context.getResources().getDisplayMetrics().density; | ||
| 50 | + return (pxVal / scale); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * px转sp | ||
| 55 | + * | ||
| 56 | + * @param context | ||
| 57 | + * @param pxVal | ||
| 58 | + * @return | ||
| 59 | + */ | ||
| 60 | + public static float px2sp(@NonNull Context context, float pxVal) { | ||
| 61 | + return (pxVal / context.getResources().getDisplayMetrics().scaledDensity); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | +} |
app/src/main/java/com/cnlive/gundam/video/utils/NetworkChangeReceive.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.utils; | ||
| 2 | + | ||
| 3 | +import android.content.BroadcastReceiver; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.Intent; | ||
| 6 | +import android.net.ConnectivityManager; | ||
| 7 | +import android.net.NetworkInfo; | ||
| 8 | + | ||
| 9 | +import com.cnlive.gundam.video.model.NetStatusEvent; | ||
| 10 | + | ||
| 11 | +import org.greenrobot.eventbus.EventBus; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by gujun on 2017/6/23. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +public class NetworkChangeReceive extends BroadcastReceiver { | ||
| 18 | + @Override | ||
| 19 | + public void onReceive(Context context, Intent intent) { | ||
| 20 | + ConnectivityManager manager = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE); | ||
| 21 | + NetworkInfo networkInfo = manager.getActiveNetworkInfo(); | ||
| 22 | + if (networkInfo != null && networkInfo.isAvailable()) { | ||
| 23 | + NetworkInfo.State mobile = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); | ||
| 24 | + NetworkInfo.State wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState(); | ||
| 25 | + if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING) { | ||
| 26 | + EventBus.getDefault().post(new NetStatusEvent(NetStatusEvent.NET_MOBILE)); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + if (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) { | ||
| 30 | + EventBus.getDefault().post(new NetStatusEvent(NetStatusEvent.NET_WIFI)); | ||
| 31 | + } | ||
| 32 | + } else { | ||
| 33 | + EventBus.getDefault().post(new NetStatusEvent(NetStatusEvent.NET_DISCONNECT)); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +} |
app/src/main/java/com/cnlive/gundam/video/utils/NetworkUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.utils; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.net.ConnectivityManager; | ||
| 5 | +import android.net.NetworkInfo; | ||
| 6 | + | ||
| 7 | +public class NetworkUtil { | ||
| 8 | + | ||
| 9 | + private static ConnectivityManager connectManager; | ||
| 10 | + | ||
| 11 | + private static void initConnectivityManager(Context context) { | ||
| 12 | + if (connectManager == null) connectManager = (ConnectivityManager) | ||
| 13 | + context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 检测网络是否可用 | ||
| 18 | + */ | ||
| 19 | + public static boolean isConnectInternet(Context context) { | ||
| 20 | + initConnectivityManager(context); | ||
| 21 | + | ||
| 22 | + if (connectManager != null) { | ||
| 23 | + NetworkInfo networkinfo = connectManager.getActiveNetworkInfo(); | ||
| 24 | + return networkinfo != null && networkinfo.isAvailable(); | ||
| 25 | + } | ||
| 26 | + return false; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 检测是否是手机网络 | ||
| 31 | + * @param context | ||
| 32 | + * @return | ||
| 33 | + */ | ||
| 34 | + public static boolean isMobileNet(Context context) { | ||
| 35 | + ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
| 36 | + if (connectivity == null || connectivity.getActiveNetworkInfo() == null) | ||
| 37 | + return false; | ||
| 38 | + return connectivity.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_MOBILE; | ||
| 39 | + | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | +} | ||
| 0 | \ No newline at end of file | 43 | \ No newline at end of file |
app/src/main/java/com/cnlive/gundam/video/utils/PlayerUtils.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.utils; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.pm.ActivityInfo; | ||
| 6 | +import android.view.WindowManager; | ||
| 7 | + | ||
| 8 | +import java.util.Locale; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by gujun on 2017/4/27. | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | +public class PlayerUtils { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 播放时间格式化 | ||
| 18 | + * | ||
| 19 | + * @param second | ||
| 20 | + * @return | ||
| 21 | + */ | ||
| 22 | + public static String stringForTime(long second) { | ||
| 23 | + int totalSeconds = (int) second; | ||
| 24 | + | ||
| 25 | + int seconds = totalSeconds % 60; | ||
| 26 | + int minutes = (totalSeconds / 60) % 60; | ||
| 27 | + int hours = totalSeconds / 3600; | ||
| 28 | + | ||
| 29 | + if (hours > 0) { | ||
| 30 | + return String.format(Locale.getDefault(), "%d:%02d:%02d", hours, minutes, seconds); | ||
| 31 | + } else { | ||
| 32 | + return String.format(Locale.getDefault(), "%02d:%02d", minutes, seconds); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public static int checkSize(int curValue, int minValue, int maxValue) { | ||
| 37 | + if (curValue < minValue) | ||
| 38 | + curValue = minValue; | ||
| 39 | + else if (curValue > maxValue) | ||
| 40 | + curValue = maxValue; | ||
| 41 | + return curValue; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 设置状态栏显示与隐藏 | ||
| 46 | + * | ||
| 47 | + * @param show | ||
| 48 | + */ | ||
| 49 | + public static void setStatusBarVisibility(Context context, boolean show) { | ||
| 50 | + if (context != null) { | ||
| 51 | + if (show) { | ||
| 52 | + ((Activity)context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
| 53 | + } else { | ||
| 54 | + ((Activity)context).getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 获取当前屏幕方向 | ||
| 61 | + * @return | ||
| 62 | + */ | ||
| 63 | + public static boolean isPortrait(Context context) { | ||
| 64 | + return ((Activity) context).getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; | ||
| 65 | + } | ||
| 66 | +} |
app/src/main/java/com/cnlive/gundam/video/utils/VideoRateUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.utils; | ||
| 2 | + | ||
| 3 | +import android.text.TextUtils; | ||
| 4 | + | ||
| 5 | +import com.cnlive.gundam.video.view.PlayerControllerView; | ||
| 6 | +import com.cnlive.libs.util.Config; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Created by gujun on 2017/5/25. | ||
| 10 | + */ | ||
| 11 | + | ||
| 12 | +public class VideoRateUtil { | ||
| 13 | + | ||
| 14 | + public static String getRateText(int rateType) { | ||
| 15 | + switch (rateType) { | ||
| 16 | + case PlayerControllerView.RATE_L: | ||
| 17 | + return "流畅"; | ||
| 18 | + case PlayerControllerView.RATE_M: | ||
| 19 | + return "标清"; | ||
| 20 | + case PlayerControllerView.RATE_H: | ||
| 21 | + return "高清"; | ||
| 22 | + case PlayerControllerView.RATE_HH: | ||
| 23 | + return "超高清"; | ||
| 24 | + } | ||
| 25 | + return "标清"; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public static String getRateText(String rate) { | ||
| 29 | + switch (rate) { | ||
| 30 | + case Config.TYPE_PLAY_RATE_1: | ||
| 31 | + return "流畅"; | ||
| 32 | + case Config.TYPE_PLAY_RATE_2: | ||
| 33 | + return "标清"; | ||
| 34 | + case Config.TYPE_PLAY_RATE_3: | ||
| 35 | + return "高清"; | ||
| 36 | + case Config.TYPE_PLAY_RATE_4: | ||
| 37 | + return "超高清"; | ||
| 38 | + } | ||
| 39 | + return "标清"; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + //判断后台给的码率是否含有当前码率 | ||
| 43 | + public static boolean hasCurRate(String rates, int curRate) { | ||
| 44 | + if(TextUtils.isEmpty(rates)) return false; | ||
| 45 | + switch (curRate) { | ||
| 46 | + case PlayerControllerView.RATE_L: | ||
| 47 | + return rates.contains("1"); | ||
| 48 | + case PlayerControllerView.RATE_M: | ||
| 49 | + return rates.contains("2"); | ||
| 50 | + case PlayerControllerView.RATE_H: | ||
| 51 | + return rates.contains("3"); | ||
| 52 | + case PlayerControllerView.RATE_HH: | ||
| 53 | + return rates.contains("4"); | ||
| 54 | + } | ||
| 55 | + return false; | ||
| 56 | + } | ||
| 57 | +} |
app/src/main/java/com/cnlive/gundam/video/view/BaseVideoView.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.view; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.databinding.DataBindingUtil; | ||
| 5 | +import android.util.AttributeSet; | ||
| 6 | +import android.util.Log; | ||
| 7 | +import android.view.LayoutInflater; | ||
| 8 | +import android.widget.RelativeLayout; | ||
| 9 | + | ||
| 10 | +import com.cnlive.gundam.R; | ||
| 11 | +import com.cnlive.gundam.databinding.LayoutVideoViewBinding; | ||
| 12 | +import com.cnlive.gundam.video.model.DataSource; | ||
| 13 | +import com.cnlive.gundam.video.model.VideoModel; | ||
| 14 | +import com.cnlive.libs.util.Config; | ||
| 15 | +import com.cnlive.libs.util.SharedPreferencesHelper; | ||
| 16 | +import com.cnlive.libs.video.video.VideoStatusUtil; | ||
| 17 | +import com.cnlive.libs.video.video.base.IMediaPlayer; | ||
| 18 | +import com.cnlive.libs.video.video.base.ISwitchVideoView; | ||
| 19 | +import com.cnlive.libs.video.video.base.IVideoStatus; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Created by gujun on 2017/4/5. | ||
| 23 | + * 这个里只是关于播放器和ugc直播播放状态的相关处理 | ||
| 24 | + */ | ||
| 25 | + | ||
| 26 | +public abstract class BaseVideoView extends RelativeLayout implements | ||
| 27 | + IMediaPlayer.OnCompletionListener, IMediaPlayer.OnInfoListener, | ||
| 28 | + IMediaPlayer.OnErrorListener, IMediaPlayer.OnPlayStateListener, | ||
| 29 | + IMediaPlayer.OnSeekCompleteListener, IMediaPlayer.OnPreparedListener, | ||
| 30 | + IMediaPlayer.OnBufferingUpdateListener, ISwitchVideoView.OnSwitchVideoPreparedListener, | ||
| 31 | + ISwitchVideoView.OnSwitchVideoErrorListener, ISwitchVideoView.OnSwitchVideoCompleteListener { | ||
| 32 | + | ||
| 33 | + protected Context mContext; | ||
| 34 | + protected LayoutVideoViewBinding binding; | ||
| 35 | + | ||
| 36 | + //记录当前视频播放状态 | ||
| 37 | + protected boolean isPlay = false; | ||
| 38 | + //当前播放器的播放进度 重试的时候从此时间播放 | ||
| 39 | + private long curPlayPosition = -1; | ||
| 40 | + //prepare后是否seekTo 为了重试后seekComplete过滤 | ||
| 41 | + private boolean isPrepareSeek = false; | ||
| 42 | + | ||
| 43 | + //播放数据 | ||
| 44 | + protected VideoModel videoModel; | ||
| 45 | + //记录当前是否是直播节目 | ||
| 46 | + protected static boolean isLive; | ||
| 47 | + //记录当前视频是否能播 | ||
| 48 | + protected boolean canPlay = true; | ||
| 49 | + //本地缓存数据工具类 | ||
| 50 | + private SharedPreferencesHelper sharedPreferencesHelper; | ||
| 51 | + //播放进度保存至本地缓存的标识前缀 | ||
| 52 | + private final String CUR_PLAY_POSITION_PRE = "CurPlayPosition_"; | ||
| 53 | + //保存切换码率之前的码率 | ||
| 54 | + private String preRate = Config.TYPE_PLAY_RATE_2; | ||
| 55 | + //保存当前要切换的码率 | ||
| 56 | + private String curRate = ""; | ||
| 57 | + //记录当前是否正在切换视频 | ||
| 58 | + protected boolean switchingVideoRate = false; | ||
| 59 | + | ||
| 60 | + private DataSource curDataSource; | ||
| 61 | + | ||
| 62 | + private OnVideoViewPlayStatusListener l; | ||
| 63 | + | ||
| 64 | + public BaseVideoView(Context context) { | ||
| 65 | + this(context, null); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public BaseVideoView(Context context, AttributeSet attrs) { | ||
| 69 | + this(context, attrs, 0); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public BaseVideoView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 73 | + super(context, attrs, defStyleAttr); | ||
| 74 | + this.mContext = context; | ||
| 75 | + init(); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public void setVideoViewPlayStatus(OnVideoViewPlayStatusListener listener) { | ||
| 79 | + l = listener; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + protected void init() { | ||
| 83 | + sharedPreferencesHelper = SharedPreferencesHelper.getInstance(getContext()); | ||
| 84 | + binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.layout_video_view, this, true); | ||
| 85 | + binding.videoView.setOnPreparedListener(this); | ||
| 86 | + binding.videoView.setOnInfoListener(this); | ||
| 87 | + binding.videoView.setOnErrorListener(this); | ||
| 88 | + binding.videoView.setOnCompletionListener(this); | ||
| 89 | + binding.videoView.setOnSeekCompleteListener(this); | ||
| 90 | + binding.videoView.setOnPlayStateListener(this); | ||
| 91 | + binding.videoView.setOnBufferingUpdateListener(this); | ||
| 92 | + binding.videoView.setScreenOnWhilePlaying(true); | ||
| 93 | + binding.videoView.setOnSwitchVideoPreparedListener(this); | ||
| 94 | + binding.videoView.setOnSwitchVideoErrorListener(this); | ||
| 95 | + binding.videoView.setOnSwitchVideoCompleteListener(this); | ||
| 96 | + setKeepScreenOn(true); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public void setDataSource() { | ||
| 100 | + //只有ugcLive视频才有状态监听 | ||
| 101 | + if (videoModel.getType().equals(VideoView.TYPE_UGC_LIVE)) { | ||
| 102 | + VideoStatusUtil.setOnVideoPlayStatusCallback(mOnVideoStatusCallback); | ||
| 103 | + VideoStatusUtil.init(videoModel.getId()); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + if (isLive) { | ||
| 107 | + curPlayPosition = -1; | ||
| 108 | + binding.videoView.setDataSource(curDataSource = new DataSource(videoModel.getId(), Config.TYPE_LIVE, Config.TYPE_PLAY_RATE_2)); | ||
| 109 | + } else { | ||
| 110 | + curPlayPosition = sharedPreferencesHelper.getLong(CUR_PLAY_POSITION_PRE + videoModel.getId()); | ||
| 111 | + binding.videoView.setDataSource(curDataSource = new DataSource(videoModel.getId(), Config.TYPE_VOD, Config.TYPE_PLAY_RATE_2)); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + preRate = Config.TYPE_PLAY_RATE_2; | ||
| 115 | + | ||
| 116 | + | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * 设置当前播放进度 | ||
| 121 | + * | ||
| 122 | + * @param curPosition | ||
| 123 | + */ | ||
| 124 | + protected void setPlayPosition(long curPosition) { | ||
| 125 | + curPlayPosition = curPosition; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public void onResume() { | ||
| 129 | + if (!binding.videoView.isPlaying() && isPlay) { | ||
| 130 | + setPlayState(true); | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public void onPause() { | ||
| 135 | + if (binding.videoView.isPlaying()) { | ||
| 136 | + setPlayState(false); | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public void onDestroy() { | ||
| 141 | + binding.videoView.release(); | ||
| 142 | + VideoStatusUtil.quit(); | ||
| 143 | + saveCurPlayPosition(); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + //保存当前播放视频的播放进度 | ||
| 147 | + protected void saveCurPlayPosition() { | ||
| 148 | + if (!isLive && curDataSource != null && sharedPreferencesHelper != null) { | ||
| 149 | + sharedPreferencesHelper.setValue(CUR_PLAY_POSITION_PRE + curDataSource.getDataSourceId(), curPlayPosition); | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + protected void retry() { | ||
| 154 | + binding.videoView.reload(); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + protected void replay() { | ||
| 158 | + isPrepareSeek = true; | ||
| 159 | + binding.videoView.seekTo(0); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * 设置播放状态 | ||
| 164 | + * | ||
| 165 | + * @param isPlay | ||
| 166 | + */ | ||
| 167 | + protected void setPlayState(boolean isPlay) { | ||
| 168 | + if (isPlay) binding.videoView.start(); | ||
| 169 | + else binding.videoView.pause(); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + /** | ||
| 173 | + * 播放按钮点击 | ||
| 174 | + */ | ||
| 175 | + public void playBtnClick() { | ||
| 176 | + isPlay = !isPlay; | ||
| 177 | + setPlayState(isPlay); | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + /** | ||
| 181 | + * 切换视频码率 | ||
| 182 | + * | ||
| 183 | + * @param rate | ||
| 184 | + */ | ||
| 185 | + public void switchVideoRate(String rate) { | ||
| 186 | + //TODO 换成无缝切换 | ||
| 187 | + curRate = rate; | ||
| 188 | + if (binding.controllerView != null) | ||
| 189 | + binding.controllerView.setSwitchRateType(PlayerControllerView.SWITCH_RATE_START, curRate); | ||
| 190 | + curDataSource.setRate(rate); | ||
| 191 | + if (binding.videoView != null) | ||
| 192 | + binding.videoView.switchVideo(curDataSource); | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + | ||
| 196 | +//----------------------播放器相关回调 start------------------------------- | ||
| 197 | + | ||
| 198 | + @Override | ||
| 199 | + public void onCompletion(IMediaPlayer iMediaPlayer) { | ||
| 200 | + isPlay = false; | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + @Override | ||
| 204 | + public boolean onError(IMediaPlayer iMediaPlayer, int i, int i1) { | ||
| 205 | + isPlay = false; | ||
| 206 | + return false; | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + @Override | ||
| 210 | + public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i1) { | ||
| 211 | + return false; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + @Override | ||
| 215 | + public void onPlayState(boolean isPlay) { | ||
| 216 | + if (l != null) l.onVideoViewPlayStatus(isPlay); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + @Override | ||
| 220 | + public void onPrepared(IMediaPlayer iMediaPlayer) { | ||
| 221 | + if (curPlayPosition > 0) { | ||
| 222 | + isPrepareSeek = true; | ||
| 223 | + iMediaPlayer.seekTo(curPlayPosition); | ||
| 224 | + } else { | ||
| 225 | + if (canPlay && !iMediaPlayer.getPlayState()) { | ||
| 226 | + setPlayState(true); | ||
| 227 | + isPlay = true; | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + @Override | ||
| 233 | + public void onSeekComplete(IMediaPlayer iMediaPlayer) { | ||
| 234 | + if (!isPrepareSeek) return; | ||
| 235 | + isPrepareSeek = false; | ||
| 236 | + setPlayState(true); | ||
| 237 | + isPlay = true; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + @Override | ||
| 241 | + public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i) { | ||
| 242 | + | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + | ||
| 246 | + @Override | ||
| 247 | + public void onSwitchVideoError(IMediaPlayer iMediaPlayer, int i, int i1) { | ||
| 248 | + binding.videoView.releaseSwitchVideo(); | ||
| 249 | + switchingVideoRate = false; | ||
| 250 | + //切换失败继续播切换之前的码率 | ||
| 251 | + curDataSource.setRate(preRate); | ||
| 252 | + if (binding.controllerView != null) { | ||
| 253 | + binding.controllerView.setCurRate(preRate); | ||
| 254 | + binding.controllerView.setSwitchRateType(PlayerControllerView.SWITCH_RATE_ERROR, curRate); | ||
| 255 | + } | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + @Override | ||
| 259 | + public void onSwitchVideoComplete(IMediaPlayer iMediaPlayer) { | ||
| 260 | + switchingVideoRate = false; | ||
| 261 | + if (binding.controllerView != null) | ||
| 262 | + binding.controllerView.setSwitchRateType(PlayerControllerView.SWITCH_RATE_FINISH, curRate); | ||
| 263 | + preRate = curRate; | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + @Override | ||
| 267 | + public void onSwitchVideoPrepared(IMediaPlayer iMediaPlayer) { | ||
| 268 | + switchingVideoRate = true; | ||
| 269 | + if (binding.videoView != null) { | ||
| 270 | + binding.videoView.switchVideoStart(binding.videoView.getCurrentPosition()); | ||
| 271 | + } | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + | ||
| 275 | +// ---------------------ugc直播状态的回调--------------------------------- | ||
| 276 | + | ||
| 277 | + private IVideoStatus.VideoStatusCallback mOnVideoStatusCallback = new IVideoStatus.VideoStatusCallback() { | ||
| 278 | + @Override | ||
| 279 | + public void onStatusChange(int status) { | ||
| 280 | + switch (status) { | ||
| 281 | + case IVideoStatus.MEDIA_STATUS_LIVING: | ||
| 282 | + //直播中' | ||
| 283 | + canPlay = true; | ||
| 284 | + if (!binding.videoView.getPlayState()) { | ||
| 285 | + binding.videoView.reload(); | ||
| 286 | + binding.infoView.show(PlayerInfoView.SHOW_BUFFERING); | ||
| 287 | + } | ||
| 288 | + break; | ||
| 289 | + case IVideoStatus.MEDIA_STATUS_LEAVE: | ||
| 290 | + //主播暂时离开 | ||
| 291 | + canPlay = false; | ||
| 292 | + binding.videoView.stop(); | ||
| 293 | + binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, mContext.getString(R.string.player_status_leave)); | ||
| 294 | + break; | ||
| 295 | + case IVideoStatus.MEDIA_STATUS_END: | ||
| 296 | + //直播结束 | ||
| 297 | + canPlay = false; | ||
| 298 | + binding.videoView.stop(); | ||
| 299 | + binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, mContext.getString(R.string.player_status_end)); | ||
| 300 | + break; | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + @Override | ||
| 306 | + public void onError(int what, String extra) { | ||
| 307 | + Log.e("ugcLive status", "onError: " + extra); | ||
| 308 | + } | ||
| 309 | + }; | ||
| 310 | + | ||
| 311 | + //播放器播放状态监听 | ||
| 312 | + public interface OnVideoViewPlayStatusListener { | ||
| 313 | + void onVideoViewPlayStatus(boolean isPlay); | ||
| 314 | + } | ||
| 315 | +} |
app/src/main/java/com/cnlive/gundam/video/view/PlayerAccelerometerSensor.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.view; | ||
| 2 | + | ||
| 3 | +import android.annotation.SuppressLint; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.pm.ActivityInfo; | ||
| 6 | +import android.hardware.Sensor; | ||
| 7 | +import android.hardware.SensorEvent; | ||
| 8 | +import android.hardware.SensorEventListener; | ||
| 9 | +import android.hardware.SensorManager; | ||
| 10 | + | ||
| 11 | +@SuppressLint("InlinedApi") | ||
| 12 | +public class PlayerAccelerometerSensor { | ||
| 13 | + | ||
| 14 | + public static final int ORIENTATION_LANDSCAPE = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; | ||
| 15 | + public static final int ORIENTATION_PORTRAIT = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; | ||
| 16 | + public static final int ORIENTATION_REVERSE_LANDSCAPE = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; | ||
| 17 | + private Context context; | ||
| 18 | + private SensorManager mSensorManager = null; | ||
| 19 | + private Sensor mSensor = null; | ||
| 20 | + private ScreenOrientationListener listener; | ||
| 21 | + private int orientation = -1; | ||
| 22 | + private double x, y; | ||
| 23 | + private double boundaryValue; | ||
| 24 | + | ||
| 25 | + public interface ScreenOrientationListener { | ||
| 26 | + public void onOrientationChange(int orientation); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public PlayerAccelerometerSensor(Context context) { | ||
| 30 | + this.context = context; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public void unregister() { | ||
| 34 | + if (mSensorManager != null) | ||
| 35 | + mSensorManager.unregisterListener(lsn); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void register() { | ||
| 39 | + boundaryValue = 8.5d; | ||
| 40 | + mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); | ||
| 41 | + mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); | ||
| 42 | + mSensorManager.registerListener(lsn, mSensor, SensorManager.SENSOR_DELAY_UI); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + private SensorEventListener lsn = new SensorEventListener() { | ||
| 46 | + | ||
| 47 | + @SuppressWarnings("deprecation") | ||
| 48 | + @Override | ||
| 49 | + public void onSensorChanged(SensorEvent event) { | ||
| 50 | + x = event.values[SensorManager.DATA_X]; | ||
| 51 | + y = event.values[SensorManager.DATA_Y]; | ||
| 52 | + if (x > boundaryValue && orientation != ORIENTATION_LANDSCAPE) { | ||
| 53 | + orientation_change(orientation = ORIENTATION_LANDSCAPE); | ||
| 54 | + } else if (y > boundaryValue && orientation != ORIENTATION_PORTRAIT) { | ||
| 55 | + orientation_change(orientation = ORIENTATION_PORTRAIT); | ||
| 56 | + } else if (x < (-boundaryValue) | ||
| 57 | + && orientation != ORIENTATION_REVERSE_LANDSCAPE) { | ||
| 58 | + orientation_change(orientation = ORIENTATION_REVERSE_LANDSCAPE); | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void onAccuracyChanged(Sensor sensor, int accuracy) { | ||
| 64 | + | ||
| 65 | + } | ||
| 66 | + }; | ||
| 67 | + | ||
| 68 | + public int getOrientation() { | ||
| 69 | + return orientation; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public void setScreenOrientationListener(ScreenOrientationListener listener) { | ||
| 73 | + this.listener = listener; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void orientation_change(int orientation) { | ||
| 77 | + if (listener != null) listener.onOrientationChange(orientation); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | +} |
app/src/main/java/com/cnlive/gundam/video/view/PlayerControllerView.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.pm.ActivityInfo; | ||
| 6 | +import android.databinding.DataBindingUtil; | ||
| 7 | +import android.databinding.ObservableBoolean; | ||
| 8 | +import android.databinding.ObservableField; | ||
| 9 | +import android.databinding.ObservableInt; | ||
| 10 | +import android.databinding.ObservableLong; | ||
| 11 | +import android.databinding.ViewDataBinding; | ||
| 12 | +import android.os.Handler; | ||
| 13 | +import android.os.Message; | ||
| 14 | +import android.text.TextUtils; | ||
| 15 | +import android.util.AttributeSet; | ||
| 16 | +import android.view.LayoutInflater; | ||
| 17 | +import android.view.View; | ||
| 18 | +import android.widget.RelativeLayout; | ||
| 19 | +import android.widget.SeekBar; | ||
| 20 | + | ||
| 21 | +import com.android.databinding.library.baseAdapters.BR; | ||
| 22 | +import com.cnlive.gundam.R; | ||
| 23 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 24 | +import com.cnlive.gundam.video.utils.VideoRateUtil; | ||
| 25 | +import com.cnlive.libs.util.Config; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Created by gujun on 2017/4/26. | ||
| 29 | + */ | ||
| 30 | + | ||
| 31 | +public class PlayerControllerView extends RelativeLayout implements SeekBar.OnSeekBarChangeListener { | ||
| 32 | + public static final int ID_CLICK_PLAY_BUTTON = 0x2001; | ||
| 33 | + | ||
| 34 | + public static final int VOD_L = 0x1001; | ||
| 35 | + public static final int VOD_P = 0x1002; | ||
| 36 | + public static final int LIVE_L = 0x1003; | ||
| 37 | + public static final int LIVE_P = 0x1004; | ||
| 38 | + public static final int UGC_VOD_L = 0x1005; | ||
| 39 | + public static final int UGC_VOD_P = 0x1006; | ||
| 40 | + public static final int UGC_LIVE_L = 0x1007; | ||
| 41 | + public static final int UGC_LIVE_P = 0x1008; | ||
| 42 | + | ||
| 43 | + public static final int RATE_L = 0x4001; | ||
| 44 | + public static final int RATE_M = 0x4002; | ||
| 45 | + public static final int RATE_H = 0x4003; | ||
| 46 | + public static final int RATE_HH = 0x4004; | ||
| 47 | + | ||
| 48 | + public static final int SWITCH_RATE_START = 0x5001; | ||
| 49 | + public static final int SWITCH_RATE_FINISH = 0x5002; | ||
| 50 | + public static final int SWITCH_RATE_ERROR = 0x5003; | ||
| 51 | + | ||
| 52 | + private static final int HIDE_RATE_TOAST = 0x6001; | ||
| 53 | + private static final int HIDE_RATE_TOAST_DELAY = 2000; | ||
| 54 | + | ||
| 55 | + private Context mContext; | ||
| 56 | + private VideoControllerListener l; | ||
| 57 | + | ||
| 58 | + private ViewDataBinding binding; | ||
| 59 | + | ||
| 60 | + //视频title | ||
| 61 | + private ObservableField<String> observableTitle; | ||
| 62 | + //controller是否显示 | ||
| 63 | + private ObservableBoolean observableShow; | ||
| 64 | + //当时是否是播放状态 | ||
| 65 | + private ObservableBoolean observableIsPlay; | ||
| 66 | + //当前播放进度 | ||
| 67 | + private ObservableLong observableCurProgress; | ||
| 68 | + //总的播放进度 | ||
| 69 | + private ObservableLong observableDurProgress; | ||
| 70 | + //记录当前视频是否是ugc | ||
| 71 | + private boolean isUgc = false; | ||
| 72 | + | ||
| 73 | + //记录当前选择的码率 | ||
| 74 | + private ObservableInt observableRateType; | ||
| 75 | + //记录当前是否显示码率按钮 | ||
| 76 | + private ObservableBoolean observableHasRate; | ||
| 77 | + //记录当前码率列表布局是否显示 | ||
| 78 | + private ObservableBoolean observableShowRateListLayout; | ||
| 79 | + //记录当前码率列表布局是否显示 | ||
| 80 | + private ObservableBoolean observableShowRateToastLayout; | ||
| 81 | + //记录切换码率视频状态 | ||
| 82 | + private ObservableInt observableSwitchRateType; | ||
| 83 | + //记录要切换的码率文字 | ||
| 84 | + private ObservableField<String> observableSwitchRateStr; | ||
| 85 | + //记录后台给的码率字符串"1,2,3,4"格式 | ||
| 86 | + private ObservableField<String> observableRateStr; | ||
| 87 | + | ||
| 88 | + private Handler mHandler = new Handler() { | ||
| 89 | + @Override | ||
| 90 | + public void handleMessage(Message msg) { | ||
| 91 | + super.handleMessage(msg); | ||
| 92 | + switch (msg.what) { | ||
| 93 | + case HIDE_RATE_TOAST: | ||
| 94 | + observableShowRateToastLayout.set(false); | ||
| 95 | + break; | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + }; | ||
| 99 | + | ||
| 100 | + public PlayerControllerView(Context context) { | ||
| 101 | + this(context, null); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public PlayerControllerView(Context context, AttributeSet attrs) { | ||
| 105 | + this(context, attrs, 0); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public PlayerControllerView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 109 | + super(context, attrs, defStyleAttr); | ||
| 110 | + mContext = context; | ||
| 111 | + init(); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + private void init() { | ||
| 115 | + observableTitle = new ObservableField<>(); | ||
| 116 | + observableShow = new ObservableBoolean(); | ||
| 117 | + observableIsPlay = new ObservableBoolean(); | ||
| 118 | + observableCurProgress = new ObservableLong(); | ||
| 119 | + observableDurProgress = new ObservableLong(); | ||
| 120 | + observableRateType = new ObservableInt(); | ||
| 121 | + observableShowRateListLayout = new ObservableBoolean(); | ||
| 122 | + observableShowRateToastLayout = new ObservableBoolean(); | ||
| 123 | + observableSwitchRateType = new ObservableInt(); | ||
| 124 | + observableHasRate = new ObservableBoolean(); | ||
| 125 | + observableRateStr = new ObservableField<>(); | ||
| 126 | + observableSwitchRateStr = new ObservableField<>(); | ||
| 127 | + observableShow.set(true); | ||
| 128 | + observableRateType.set(RATE_M); | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + public void setOnControllerListener(VideoControllerListener listener) { | ||
| 132 | + l = listener; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public void setControllerLayout(int type) { | ||
| 136 | + if (binding != null) | ||
| 137 | + binding.unbind(); | ||
| 138 | + switch (type) { | ||
| 139 | + case VOD_P: | ||
| 140 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_vod_p)); | ||
| 141 | + binding.setVariable(BR.playerControllerView, this); | ||
| 142 | + binding.setVariable(BR.title, observableTitle); | ||
| 143 | + binding.setVariable(BR.showController, observableShow); | ||
| 144 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 145 | + binding.setVariable(BR.durProgress, observableDurProgress); | ||
| 146 | + binding.setVariable(BR.curProgress, observableCurProgress); | ||
| 147 | + isUgc = false; | ||
| 148 | + break; | ||
| 149 | + case VOD_L: | ||
| 150 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_vod_l)); | ||
| 151 | + binding.setVariable(BR.playerControllerView, this); | ||
| 152 | + binding.setVariable(BR.rateType, observableRateType); | ||
| 153 | + binding.setVariable(BR.rateListStr, observableRateStr); | ||
| 154 | + binding.setVariable(BR.hasRate, observableHasRate); | ||
| 155 | + binding.setVariable(BR.showRateListLayout, observableShowRateListLayout); | ||
| 156 | + binding.setVariable(BR.showRateToastLayout, observableShowRateToastLayout); | ||
| 157 | + binding.setVariable(BR.curSwitchRateType, observableSwitchRateType); | ||
| 158 | + binding.setVariable(BR.curSwitchRateStr, observableSwitchRateStr); | ||
| 159 | + binding.setVariable(BR.title, observableTitle); | ||
| 160 | + binding.setVariable(BR.showController, observableShow); | ||
| 161 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 162 | + binding.setVariable(BR.durProgress, observableDurProgress); | ||
| 163 | + binding.setVariable(BR.curProgress, observableCurProgress); | ||
| 164 | + isUgc = false; | ||
| 165 | + break; | ||
| 166 | + case LIVE_P: | ||
| 167 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_live_p)); | ||
| 168 | + binding.setVariable(BR.playerControllerView, this); | ||
| 169 | + binding.setVariable(BR.title, observableTitle); | ||
| 170 | + binding.setVariable(BR.showController, observableShow); | ||
| 171 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 172 | + isUgc = false; | ||
| 173 | + break; | ||
| 174 | + case LIVE_L: | ||
| 175 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_live_l)); | ||
| 176 | + binding.setVariable(BR.playerControllerView, this); | ||
| 177 | + binding.setVariable(BR.rateType, observableRateType); | ||
| 178 | + binding.setVariable(BR.rateListStr, observableRateStr); | ||
| 179 | + binding.setVariable(BR.hasRate, observableHasRate); | ||
| 180 | + binding.setVariable(BR.showRateListLayout, observableShowRateListLayout); | ||
| 181 | + binding.setVariable(BR.showRateToastLayout, observableShowRateToastLayout); | ||
| 182 | + binding.setVariable(BR.curSwitchRateType, observableSwitchRateType); | ||
| 183 | + binding.setVariable(BR.curSwitchRateStr, observableSwitchRateStr); | ||
| 184 | + binding.setVariable(BR.title, observableTitle); | ||
| 185 | + binding.setVariable(BR.showController, observableShow); | ||
| 186 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 187 | + isUgc = false; | ||
| 188 | + break; | ||
| 189 | + case UGC_VOD_P: | ||
| 190 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_vod_p)); | ||
| 191 | + binding.setVariable(BR.playerControllerView, this); | ||
| 192 | + binding.setVariable(BR.title, observableTitle); | ||
| 193 | + binding.setVariable(BR.showController, observableShow); | ||
| 194 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 195 | + binding.setVariable(BR.durProgress, observableDurProgress); | ||
| 196 | + binding.setVariable(BR.curProgress, observableCurProgress); | ||
| 197 | + isUgc = true; | ||
| 198 | + break; | ||
| 199 | + case UGC_VOD_L: | ||
| 200 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_vod_l)); | ||
| 201 | + binding.setVariable(BR.playerControllerView, this); | ||
| 202 | + binding.setVariable(BR.title, observableTitle); | ||
| 203 | + binding.setVariable(BR.showController, observableShow); | ||
| 204 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 205 | + binding.setVariable(BR.durProgress, observableDurProgress); | ||
| 206 | + binding.setVariable(BR.curProgress, observableCurProgress); | ||
| 207 | + isUgc = true; | ||
| 208 | + break; | ||
| 209 | + case UGC_LIVE_P: | ||
| 210 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_live_p)); | ||
| 211 | + binding.setVariable(BR.playerControllerView, this); | ||
| 212 | + binding.setVariable(BR.title, observableTitle); | ||
| 213 | + binding.setVariable(BR.showController, observableShow); | ||
| 214 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 215 | + isUgc = true; | ||
| 216 | + break; | ||
| 217 | + case UGC_LIVE_L: | ||
| 218 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_controller_ugc_live_l)); | ||
| 219 | + binding.setVariable(BR.playerControllerView, this); | ||
| 220 | + binding.setVariable(BR.title, observableTitle); | ||
| 221 | + binding.setVariable(BR.showController, observableShow); | ||
| 222 | + binding.setVariable(BR.isPlay, observableIsPlay); | ||
| 223 | + isUgc = true; | ||
| 224 | + break; | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + //获取对应的controller | ||
| 229 | + private View getView(int layout) { | ||
| 230 | + View view = LayoutInflater.from(mContext).inflate(layout, null, false); | ||
| 231 | + if (getChildCount() > 0) | ||
| 232 | + removeAllViews(); | ||
| 233 | + addView(view); | ||
| 234 | + return view; | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + //设置是否显示码率按钮 | ||
| 238 | + public void setRateInfo(String rateStr) { | ||
| 239 | + observableRateType.set(RATE_M); | ||
| 240 | + observableHasRate.set(!TextUtils.isEmpty(rateStr) && !rateStr.equals("2")); | ||
| 241 | + observableRateStr.set(rateStr); | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + //设置当前选中的码率 | ||
| 245 | + public void setCurRate(String curRate) { | ||
| 246 | + switch (curRate) { | ||
| 247 | + case Config.TYPE_PLAY_RATE_1: | ||
| 248 | + observableRateType.set(RATE_L); | ||
| 249 | + break; | ||
| 250 | + case Config.TYPE_PLAY_RATE_2: | ||
| 251 | + observableRateType.set(RATE_M); | ||
| 252 | + break; | ||
| 253 | + case Config.TYPE_PLAY_RATE_3: | ||
| 254 | + observableRateType.set(RATE_H); | ||
| 255 | + break; | ||
| 256 | + case Config.TYPE_PLAY_RATE_4: | ||
| 257 | + observableRateType.set(RATE_HH); | ||
| 258 | + break; | ||
| 259 | + } | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + //设置title | ||
| 263 | + public void setTitle(String title) { | ||
| 264 | + observableTitle.set(title); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + //设置播放状态 | ||
| 268 | + public void setIsPlay(boolean isPlay) { | ||
| 269 | + observableIsPlay.set(isPlay); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + //设置当前播放进度 | ||
| 273 | + public void setCurProgress(long curProgress) { | ||
| 274 | + observableCurProgress.set(curProgress); | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + //设置总共播放长度 | ||
| 278 | + public void setDurProgress(long durProgress) { | ||
| 279 | + observableDurProgress.set(durProgress); | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + //改变controller的显示隐藏 | ||
| 283 | + public void changeVisible() { | ||
| 284 | + //切换显示隐藏状态时,当rate布局显示时controller不修改显示状态 | ||
| 285 | + if (!observableShow.get() && observableShowRateListLayout.get()) { | ||
| 286 | + observableShowRateListLayout.set(false); | ||
| 287 | + } else { | ||
| 288 | + observableShow.set(!observableShow.get()); | ||
| 289 | + } | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + //设置切换码率提示显示和隐藏 | ||
| 293 | + public void setSwitchRateType(int switchRateType, String curRate) { | ||
| 294 | + observableSwitchRateStr.set(VideoRateUtil.getRateText(curRate)); | ||
| 295 | + observableSwitchRateType.set(switchRateType); | ||
| 296 | + if (switchRateType == SWITCH_RATE_START) { | ||
| 297 | + observableShowRateToastLayout.set(true); | ||
| 298 | + } else { | ||
| 299 | + mHandler.sendEmptyMessageDelayed(HIDE_RATE_TOAST, HIDE_RATE_TOAST_DELAY); | ||
| 300 | + } | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + //获取当前controller是否显示 | ||
| 304 | + public boolean isShow() { | ||
| 305 | + return observableShow.get(); | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + public void onClick(View v) { | ||
| 309 | + switch (v.getId()) { | ||
| 310 | + case R.id.fullScreen: | ||
| 311 | + if (PlayerUtils.isPortrait(getContext())) { | ||
| 312 | + ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | ||
| 313 | + } | ||
| 314 | + break; | ||
| 315 | + case R.id.back: | ||
| 316 | + if (!(PlayerUtils.isPortrait(getContext())) && !isUgc) { | ||
| 317 | + ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
| 318 | + } else { | ||
| 319 | + ((Activity) mContext).onBackPressed(); | ||
| 320 | + } | ||
| 321 | + break; | ||
| 322 | + case R.id.playBtn: | ||
| 323 | + if (l != null) l.onControllerViewClick(ID_CLICK_PLAY_BUTTON); | ||
| 324 | + break; | ||
| 325 | + case R.id.rate: | ||
| 326 | + if (!observableShowRateListLayout.get()) { | ||
| 327 | + observableShowRateListLayout.set(true); | ||
| 328 | + observableShow.set(false); | ||
| 329 | + } | ||
| 330 | + break; | ||
| 331 | + case R.id.rateOutClickView: | ||
| 332 | + if (!observableShow.get()) | ||
| 333 | + observableShow.set(true); | ||
| 334 | + observableShowRateListLayout.set(false); | ||
| 335 | + break; | ||
| 336 | + case R.id.rateL: | ||
| 337 | + if (observableRateType.get() != RATE_L) { | ||
| 338 | + observableShowRateListLayout.set(false); | ||
| 339 | + observableRateType.set(RATE_L); | ||
| 340 | + observableShow.set(true); | ||
| 341 | + if (l != null) l.onSwitchRate(Config.TYPE_PLAY_RATE_1); | ||
| 342 | + } | ||
| 343 | + break; | ||
| 344 | + case R.id.rateM: | ||
| 345 | + if (observableRateType.get() != RATE_M) { | ||
| 346 | + observableShowRateListLayout.set(false); | ||
| 347 | + observableRateType.set(RATE_M); | ||
| 348 | + observableShow.set(true); | ||
| 349 | + if (l != null) l.onSwitchRate(Config.TYPE_PLAY_RATE_2); | ||
| 350 | + } | ||
| 351 | + break; | ||
| 352 | + case R.id.rateH: | ||
| 353 | + if (observableRateType.get() != RATE_H) { | ||
| 354 | + observableShowRateListLayout.set(false); | ||
| 355 | + observableRateType.set(RATE_H); | ||
| 356 | + observableShow.set(true); | ||
| 357 | + if (l != null) l.onSwitchRate(Config.TYPE_PLAY_RATE_3); | ||
| 358 | + } | ||
| 359 | + break; | ||
| 360 | + case R.id.rateHH: | ||
| 361 | + if (observableRateType.get() != RATE_HH) { | ||
| 362 | + observableShowRateListLayout.set(false); | ||
| 363 | + observableRateType.set(RATE_HH); | ||
| 364 | + observableShow.set(true); | ||
| 365 | + if (l != null) l.onSwitchRate(Config.TYPE_PLAY_RATE_4); | ||
| 366 | + } | ||
| 367 | + break; | ||
| 368 | + } | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + @Override | ||
| 372 | + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | ||
| 373 | + if (l != null && fromUser) | ||
| 374 | + l.onSeekProgressChange(progress); | ||
| 375 | + | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + @Override | ||
| 379 | + public void onStartTrackingTouch(SeekBar seekBar) { | ||
| 380 | + | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + @Override | ||
| 384 | + public void onStopTrackingTouch(SeekBar seekBar) { | ||
| 385 | + if (l != null) l.onSeekComplete(); | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + @Override | ||
| 389 | + protected void onDetachedFromWindow() { | ||
| 390 | + if (mHandler != null && mHandler.hasMessages(HIDE_RATE_TOAST)) { | ||
| 391 | + mHandler.removeMessages(HIDE_RATE_TOAST); | ||
| 392 | + } | ||
| 393 | + super.onDetachedFromWindow(); | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + public interface VideoControllerListener { | ||
| 397 | + void onControllerViewClick(int id); | ||
| 398 | + | ||
| 399 | + void onSeekProgressChange(int progress); | ||
| 400 | + | ||
| 401 | + void onSeekComplete(); | ||
| 402 | + | ||
| 403 | + void onSwitchRate(String rate); | ||
| 404 | + } | ||
| 405 | +} |
app/src/main/java/com/cnlive/gundam/video/view/PlayerInfoView.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.pm.ActivityInfo; | ||
| 6 | +import android.databinding.DataBindingUtil; | ||
| 7 | +import android.databinding.ObservableBoolean; | ||
| 8 | +import android.databinding.ObservableField; | ||
| 9 | +import android.databinding.ObservableInt; | ||
| 10 | +import android.databinding.ViewDataBinding; | ||
| 11 | +import android.util.AttributeSet; | ||
| 12 | +import android.view.LayoutInflater; | ||
| 13 | +import android.view.View; | ||
| 14 | +import android.widget.RelativeLayout; | ||
| 15 | + | ||
| 16 | +import com.cnlive.gundam.BR; | ||
| 17 | +import com.cnlive.gundam.R; | ||
| 18 | +import com.cnlive.gundam.video.utils.NetworkUtil; | ||
| 19 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Created by gujun on 2017/5/22. | ||
| 23 | + */ | ||
| 24 | + | ||
| 25 | +public class PlayerInfoView extends RelativeLayout { | ||
| 26 | + public static final int ID_CLICK_INFO_RETRY = 0x3001; | ||
| 27 | + public static final int ID_CLICK_INFO_REPLAY = 0x3002; | ||
| 28 | + public static final int ID_CLICK_INFO_MOBILE_NET_PLAY = 0x3003; | ||
| 29 | + | ||
| 30 | + public static final int VIDEO_INFO_NORMAL = 0x1001; | ||
| 31 | + public static final int VIDEO_INFO_UGC = 0x1002; | ||
| 32 | + | ||
| 33 | + //隐藏所有视图 | ||
| 34 | + public static final int SHOW_NULL = 0x2001; | ||
| 35 | + //展示loading视图 | ||
| 36 | + public static final int SHOW_LOADING = 0x2002; | ||
| 37 | + //展示缓冲视图 | ||
| 38 | + public static final int SHOW_BUFFERING = 0x2003; | ||
| 39 | + //展示error视图 | ||
| 40 | + public static final int SHOW_ERROR = 0x2004; | ||
| 41 | + //展示end视图 | ||
| 42 | + public static final int SHOW_END = 0x2005; | ||
| 43 | + //展示ugcLive状态页 只有ugc直播才有此功能页 | ||
| 44 | + public static final int SHOW_UGC_LIVE_STATUS = 0x2006; | ||
| 45 | + //展示手机网视图 | ||
| 46 | + public static final int SHOW_MOBILE_NET = 0x2007; | ||
| 47 | + | ||
| 48 | + private Context mContext; | ||
| 49 | + | ||
| 50 | + private ViewDataBinding binding; | ||
| 51 | + | ||
| 52 | + //存储展示哪个视图 | ||
| 53 | + private ObservableInt observableShowType; | ||
| 54 | + //存储状态提示信息 | ||
| 55 | + private ObservableField<String> observableStatusMsg; | ||
| 56 | + //存储是否是快新闻类型 | ||
| 57 | + private ObservableBoolean observableIsNews; | ||
| 58 | + //存储是否是快新闻类型 | ||
| 59 | + private ObservableBoolean observableIsPortrait; | ||
| 60 | + // | ||
| 61 | + private ObservableField<String> observableErrorMsg; | ||
| 62 | + //记录当前view是否展示 | ||
| 63 | + private boolean isShow = false; | ||
| 64 | + //记录当前视频是否是ugc | ||
| 65 | + private boolean isUgc = false; | ||
| 66 | + | ||
| 67 | + private static VideoInfoListener l; | ||
| 68 | + | ||
| 69 | + public PlayerInfoView(Context context) { | ||
| 70 | + this(context, null); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public PlayerInfoView(Context context, AttributeSet attrs) { | ||
| 74 | + this(context, attrs, 0); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public PlayerInfoView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 78 | + super(context, attrs, defStyleAttr); | ||
| 79 | + mContext = context; | ||
| 80 | + init(); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + private void init() { | ||
| 84 | + observableShowType = new ObservableInt(); | ||
| 85 | + observableStatusMsg = new ObservableField<>(); | ||
| 86 | + observableIsNews = new ObservableBoolean(); | ||
| 87 | + observableIsPortrait = new ObservableBoolean(); | ||
| 88 | + observableErrorMsg = new ObservableField<>(); | ||
| 89 | + observableIsPortrait.set(PlayerUtils.isPortrait(getContext())); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public void setInfoListener(VideoInfoListener listener) { | ||
| 93 | + l = listener; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public void setInfoViewLayout(int infoType) { | ||
| 97 | + switch (infoType) { | ||
| 98 | + case VIDEO_INFO_NORMAL: | ||
| 99 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_info)); | ||
| 100 | + binding.setVariable(BR.playerInfoView, this); | ||
| 101 | + binding.setVariable(BR.showType, observableShowType); | ||
| 102 | + binding.setVariable(BR.isNews, observableIsNews); | ||
| 103 | + binding.setVariable(BR.isPortrait, observableIsPortrait); | ||
| 104 | + binding.setVariable(BR.errorMsg, observableErrorMsg); | ||
| 105 | + isUgc = false; | ||
| 106 | + break; | ||
| 107 | + case VIDEO_INFO_UGC: | ||
| 108 | + binding = DataBindingUtil.bind(getView(R.layout.layout_player_ugc_info)); | ||
| 109 | + binding.setVariable(BR.playerInfoView, this); | ||
| 110 | + binding.setVariable(BR.showType, observableShowType); | ||
| 111 | + binding.setVariable(BR.statusMsg, observableStatusMsg); | ||
| 112 | + binding.setVariable(BR.errorMsg, observableErrorMsg); | ||
| 113 | + isUgc = true; | ||
| 114 | + break; | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + //屏幕转换 | ||
| 119 | + public void onScreenChange(boolean isPortrait) { | ||
| 120 | + observableIsPortrait.set(isPortrait); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + //获取对应布局的视图 | ||
| 124 | + private View getView(int layout) { | ||
| 125 | + View view = LayoutInflater.from(mContext).inflate(layout, null, false); | ||
| 126 | + if (getChildCount() > 0) | ||
| 127 | + removeAllViews(); | ||
| 128 | + addView(view); | ||
| 129 | + return view; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + //当前view是否有视图显示 | ||
| 133 | + public boolean isShow() { | ||
| 134 | + return isShow; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + //展示对应视图 | ||
| 138 | + public void show(int type) { | ||
| 139 | + isShow = true; | ||
| 140 | + observableShowType.set(type); | ||
| 141 | + switch (type) { | ||
| 142 | + case SHOW_NULL: | ||
| 143 | + case SHOW_BUFFERING: | ||
| 144 | + isShow = false; | ||
| 145 | + break; | ||
| 146 | + case SHOW_ERROR: | ||
| 147 | + observableErrorMsg.set(getErrorMsg()); | ||
| 148 | + break; | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + //获取当前展示的视图的type | ||
| 153 | + public int getCurInfoType() { | ||
| 154 | + return observableShowType.get(); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public void show(int type, String statusMsg) { | ||
| 158 | + observableStatusMsg.set(statusMsg); | ||
| 159 | + show(type); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public void onClick(View v) { | ||
| 163 | + switch (v.getId()) { | ||
| 164 | + case R.id.retry: | ||
| 165 | + if (l != null) l.onInfoViewClick(ID_CLICK_INFO_RETRY); | ||
| 166 | + break; | ||
| 167 | + case R.id.replay: | ||
| 168 | + if (l != null) l.onInfoViewClick(ID_CLICK_INFO_REPLAY); | ||
| 169 | + break; | ||
| 170 | + case R.id.back: | ||
| 171 | + if (!PlayerUtils.isPortrait(getContext()) && !isUgc) { | ||
| 172 | + ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
| 173 | + } else { | ||
| 174 | + ((Activity) mContext).onBackPressed(); | ||
| 175 | + } | ||
| 176 | + break; | ||
| 177 | + case R.id.playByMobileNet: | ||
| 178 | + if (l != null) l.onInfoViewClick(ID_CLICK_INFO_MOBILE_NET_PLAY); | ||
| 179 | + break; | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * 获取播放失败提示文字 | ||
| 185 | + * | ||
| 186 | + * @return | ||
| 187 | + */ | ||
| 188 | + private String getErrorMsg() { | ||
| 189 | + return getContext().getResources().getString(NetworkUtil.isConnectInternet(getContext()) ? R.string.player_error : R.string.player_error_net); | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + public interface VideoInfoListener { | ||
| 193 | + void onInfoViewClick(int id); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | +} |
app/src/main/java/com/cnlive/gundam/video/view/PlayerTouchView.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.view; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by gujun on 2017/4/6. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import android.app.Activity; | ||
| 8 | +import android.content.Context; | ||
| 9 | +import android.databinding.DataBindingUtil; | ||
| 10 | +import android.databinding.ObservableBoolean; | ||
| 11 | +import android.databinding.ObservableInt; | ||
| 12 | +import android.media.AudioManager; | ||
| 13 | +import android.provider.Settings; | ||
| 14 | +import android.util.AttributeSet; | ||
| 15 | +import android.view.LayoutInflater; | ||
| 16 | +import android.view.MotionEvent; | ||
| 17 | +import android.view.Window; | ||
| 18 | +import android.view.WindowManager; | ||
| 19 | +import android.widget.RelativeLayout; | ||
| 20 | + | ||
| 21 | +import com.cnlive.gundam.R; | ||
| 22 | +import com.cnlive.gundam.databinding.LayoutPlayerTouchBinding; | ||
| 23 | +import com.cnlive.gundam.video.utils.DensityUtils; | ||
| 24 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * Created by gujun on 2016/9/7. | ||
| 28 | + */ | ||
| 29 | + | ||
| 30 | +public class PlayerTouchView extends RelativeLayout { | ||
| 31 | + private VideoTouchListener l; | ||
| 32 | + private static Context mContext; | ||
| 33 | + | ||
| 34 | + //点下时的x坐标 | ||
| 35 | + private int downX; | ||
| 36 | + //点下时的y坐标 | ||
| 37 | + private int downY; | ||
| 38 | + //左右控制区域的宽度 | ||
| 39 | + private int controlAreaWidth; | ||
| 40 | + //是在左边区域滑动 | ||
| 41 | + private ObservableBoolean leftArea = new ObservableBoolean(); | ||
| 42 | + //是在右边区域滑动 | ||
| 43 | + private ObservableBoolean rightArea = new ObservableBoolean(); | ||
| 44 | + //声音或亮度进度 | ||
| 45 | + private ObservableInt brightnessAndVolumeProgress = new ObservableInt(); | ||
| 46 | + //记录当前手势有没有滑动 | ||
| 47 | + private boolean isMove = false; | ||
| 48 | + //判定是点击还是滑动的范围 | ||
| 49 | + private int boundary = 30; | ||
| 50 | + //上下滑动 | ||
| 51 | + private boolean udMove = false; | ||
| 52 | + //左右滑动 | ||
| 53 | + private boolean lrMove = false; | ||
| 54 | + //声音manager | ||
| 55 | + private AudioManager audioManager; | ||
| 56 | + //开始改变前的音量 | ||
| 57 | + private int preVolume = -1; | ||
| 58 | + //时时当前声音 | ||
| 59 | + private int curVolumeProgress = -1; | ||
| 60 | + //开始改变前的亮度 | ||
| 61 | + private int preBrightness = -1; | ||
| 62 | + //时时当前亮度 | ||
| 63 | + private int curBrightnessProgress = -1; | ||
| 64 | + //时时当前播放进度百分比 | ||
| 65 | + private int curPlayProgressPercent = -1; | ||
| 66 | + | ||
| 67 | + private LayoutPlayerTouchBinding binding; | ||
| 68 | + | ||
| 69 | + public PlayerTouchView(Context context) { | ||
| 70 | + this(context, null); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public PlayerTouchView(Context context, AttributeSet attrs) { | ||
| 74 | + this(context, attrs, 0); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public PlayerTouchView(Context context, AttributeSet attrs, int defStyle) { | ||
| 78 | + super(context, attrs, defStyle); | ||
| 79 | + this.mContext = context; | ||
| 80 | + audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); | ||
| 81 | + binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.layout_player_touch, this, true); | ||
| 82 | + binding.setLeftAreaMove(leftArea); | ||
| 83 | + binding.setRightAreaMove(rightArea); | ||
| 84 | + binding.setBrightnessAndVolumeProgress(brightnessAndVolumeProgress); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public void setTouchListener(VideoTouchListener listener) { | ||
| 88 | + this.l = listener; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @Override | ||
| 92 | + public boolean onTouchEvent(MotionEvent event) { | ||
| 93 | + if (l != null && !l.canTouch()) return false; | ||
| 94 | + | ||
| 95 | + int curX = (int) event.getX(); | ||
| 96 | + int curY = (int) event.getY(); | ||
| 97 | + | ||
| 98 | + switch (event.getAction()) { | ||
| 99 | + case MotionEvent.ACTION_DOWN: | ||
| 100 | + if (l != null) l.down(); | ||
| 101 | + controlAreaWidth = getWidth() / 4; | ||
| 102 | + downX = (int) event.getX(); | ||
| 103 | + downY = (int) event.getY(); | ||
| 104 | + if (downX < controlAreaWidth) { | ||
| 105 | + if (preVolume == -1) | ||
| 106 | + preVolume = getSystemVolume(); | ||
| 107 | + brightnessAndVolumeProgress.set(preVolume * DensityUtils.dp2px(mContext, 93) / getSystemMaxVolume()); | ||
| 108 | + } else if (downX > getWidth() - controlAreaWidth) { | ||
| 109 | + if (preBrightness == -1) | ||
| 110 | + preBrightness = getSystemBrightness(); | ||
| 111 | + brightnessAndVolumeProgress.set(preBrightness * DensityUtils.dp2px(mContext, 93) / 255); | ||
| 112 | + } | ||
| 113 | + curBrightnessProgress = -1; | ||
| 114 | + curVolumeProgress = -1; | ||
| 115 | + curPlayProgressPercent = -1; | ||
| 116 | + break; | ||
| 117 | + case MotionEvent.ACTION_MOVE: | ||
| 118 | + int moveX = downX - curX; | ||
| 119 | + int moveY = downY - curY; | ||
| 120 | + if (Math.abs(moveX) > boundary || Math.abs(moveY) > boundary) { | ||
| 121 | + isMove = true; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + if (!udMove && !lrMove) { | ||
| 125 | + if (Math.abs(moveX) > boundary) { | ||
| 126 | + lrMove = true; | ||
| 127 | + } else if (Math.abs(moveY) > boundary) { | ||
| 128 | + udMove = true; | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + if (binding.operationVolumeBrightness.getVisibility() != VISIBLE) { | ||
| 133 | + leftArea.set(downX < controlAreaWidth && udMove); | ||
| 134 | + rightArea.set(downX > getWidth() - controlAreaWidth && udMove); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + if (lrMove) { | ||
| 138 | + changeProgress(moveX); | ||
| 139 | + return true; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + if (udMove) { | ||
| 143 | + if (rightArea.get()) { | ||
| 144 | + changeBrightness(moveY); | ||
| 145 | + } else if (leftArea.get()) { | ||
| 146 | + changeVolume(moveY); | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + break; | ||
| 151 | + case MotionEvent.ACTION_UP: | ||
| 152 | + if (!isMove) { | ||
| 153 | + if (l != null) l.click(); | ||
| 154 | + } else if (lrMove) { | ||
| 155 | + if (l != null) l.change_value_progress(0, true); | ||
| 156 | + } | ||
| 157 | + lrMove = false; | ||
| 158 | + udMove = false; | ||
| 159 | + isMove = false; | ||
| 160 | + leftArea.set(false); | ||
| 161 | + rightArea.set(false); | ||
| 162 | + | ||
| 163 | + preBrightness = curBrightnessProgress; | ||
| 164 | + preVolume = curVolumeProgress; | ||
| 165 | + break; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + return true; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + /** | ||
| 172 | + * 改变播放进度 | ||
| 173 | + * | ||
| 174 | + * @param moveX 移动距离 | ||
| 175 | + */ | ||
| 176 | + private void changeProgress(int moveX) { | ||
| 177 | + int curProgressPercent = -moveX * 100 / getWidth(); | ||
| 178 | + if (curPlayProgressPercent != curProgressPercent) { | ||
| 179 | + if (l != null) l.change_value_progress(curProgressPercent, false); | ||
| 180 | + curPlayProgressPercent = curProgressPercent; | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * 改变亮度 | ||
| 186 | + * | ||
| 187 | + * @param moveY 移动距离 | ||
| 188 | + */ | ||
| 189 | + private void changeBrightness(int moveY) { | ||
| 190 | + int curBrightness = PlayerUtils.checkSize(preBrightness + moveY * 255 / getHeight(), 1, 255); | ||
| 191 | + if (curBrightnessProgress == curBrightness) return; | ||
| 192 | + | ||
| 193 | + int progress = curBrightness * DensityUtils.dp2px(mContext, 93) / 255; | ||
| 194 | + brightnessAndVolumeProgress.set(progress); | ||
| 195 | + | ||
| 196 | + curBrightnessProgress = curBrightness; | ||
| 197 | + changeAppBrightness(curBrightness); | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + /** | ||
| 201 | + * 获取系统屏幕亮度 | ||
| 202 | + * | ||
| 203 | + * @return 0-255之间的范围 | ||
| 204 | + */ | ||
| 205 | + private int getSystemBrightness() { | ||
| 206 | + int systemBrightness = 0; | ||
| 207 | + try { | ||
| 208 | + systemBrightness = Settings.System.getInt(getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS); | ||
| 209 | + } catch (Settings.SettingNotFoundException e) { | ||
| 210 | + e.printStackTrace(); | ||
| 211 | + } | ||
| 212 | + return systemBrightness; | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * 改变App当前Window亮度 | ||
| 217 | + * | ||
| 218 | + * @param brightness 0-255之间的范围 | ||
| 219 | + */ | ||
| 220 | + public void changeAppBrightness(int brightness) { | ||
| 221 | + Window window = ((Activity) getContext()).getWindow(); | ||
| 222 | + WindowManager.LayoutParams lp = window.getAttributes(); | ||
| 223 | + if (brightness == -1) { | ||
| 224 | + lp.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; | ||
| 225 | + } else { | ||
| 226 | + lp.screenBrightness = (brightness <= 0 ? 1 : brightness) / 255f; | ||
| 227 | + } | ||
| 228 | + window.setAttributes(lp); | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + /** | ||
| 232 | + * 改变声音 | ||
| 233 | + * | ||
| 234 | + * @param moveY 移动距离 | ||
| 235 | + */ | ||
| 236 | + private void changeVolume(int moveY) { | ||
| 237 | + int curVolume = PlayerUtils.checkSize(preVolume + (moveY * getSystemMaxVolume() / getHeight()), 0, getSystemMaxVolume()); | ||
| 238 | + if (curVolumeProgress == curVolume) return; | ||
| 239 | + | ||
| 240 | + int progress = curVolume * DensityUtils.dp2px(mContext, 93) / getSystemMaxVolume(); | ||
| 241 | + brightnessAndVolumeProgress.set(progress); | ||
| 242 | + | ||
| 243 | + curVolumeProgress = curVolume; | ||
| 244 | + setSystemVolume(curVolume); | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + /** | ||
| 248 | + * 获取系统的媒体音量 | ||
| 249 | + * | ||
| 250 | + * @return | ||
| 251 | + */ | ||
| 252 | + private int getSystemVolume() { | ||
| 253 | + return audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + /** | ||
| 257 | + * 获取系统的媒体音量 | ||
| 258 | + * | ||
| 259 | + * @return | ||
| 260 | + */ | ||
| 261 | + private int getSystemMaxVolume() { | ||
| 262 | + return audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + /** | ||
| 266 | + * 设置系统的媒体音量 | ||
| 267 | + */ | ||
| 268 | + private void setSystemVolume(int curVolume) { | ||
| 269 | + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, curVolume, 0); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + public interface VideoTouchListener { | ||
| 273 | + | ||
| 274 | + /** | ||
| 275 | + * 改变播放进度的回调 | ||
| 276 | + * | ||
| 277 | + * @param percent 当前手势改变了进度的百分比 | ||
| 278 | + * @param update true 停止滑动,false正在滑动 | ||
| 279 | + * @return 要显示的时间字符串 | ||
| 280 | + */ | ||
| 281 | + String change_value_progress(int percent, boolean update); | ||
| 282 | + | ||
| 283 | + void click(); | ||
| 284 | + | ||
| 285 | + void down(); | ||
| 286 | + | ||
| 287 | + /** | ||
| 288 | + * 是否需要拦截touch事件 | ||
| 289 | + * | ||
| 290 | + * @return true拦截,false不拦截,其他的回调将不会执行 | ||
| 291 | + */ | ||
| 292 | + boolean canTouch(); | ||
| 293 | + } | ||
| 294 | +} | ||
| 295 | + | ||
| 296 | + |
app/src/main/java/com/cnlive/gundam/video/view/VideoView.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.view; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.databinding.ObservableBoolean; | ||
| 5 | +import android.databinding.ObservableInt; | ||
| 6 | +import android.os.Handler; | ||
| 7 | +import android.os.Message; | ||
| 8 | +import android.util.AttributeSet; | ||
| 9 | +import android.view.ViewGroup; | ||
| 10 | +import android.widget.Toast; | ||
| 11 | + | ||
| 12 | +import com.cnlive.gundam.R; | ||
| 13 | +import com.cnlive.gundam.main.utils.SharedPreferencesHelper; | ||
| 14 | +import com.cnlive.gundam.video.model.NetStatusEvent; | ||
| 15 | +import com.cnlive.gundam.video.model.VideoModel; | ||
| 16 | +import com.cnlive.gundam.video.utils.NetworkUtil; | ||
| 17 | +import com.cnlive.gundam.video.utils.PlayerUtils; | ||
| 18 | +import com.cnlive.libs.video.video.base.IMediaPlayer; | ||
| 19 | + | ||
| 20 | +import org.greenrobot.eventbus.EventBus; | ||
| 21 | +import org.greenrobot.eventbus.Subscribe; | ||
| 22 | +import org.greenrobot.eventbus.ThreadMode; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Created by gujun on 2017/4/6. | ||
| 26 | + */ | ||
| 27 | + | ||
| 28 | +public class VideoView extends BaseVideoView implements PlayerTouchView.VideoTouchListener, | ||
| 29 | + PlayerControllerView.VideoControllerListener, PlayerInfoView.VideoInfoListener { | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + //更新controller相关 | ||
| 33 | + private static final int UPDATE_CONTROLLER = 1; | ||
| 34 | + private static final int UPDATE_CONTROLLER_DELAYED = 1000; | ||
| 35 | + | ||
| 36 | + //隐藏controller相关 | ||
| 37 | + private static final int HIDE_CONTROLLER = 2; | ||
| 38 | + private static final int HIDE_CONTROLLER_DELAYED = 5000; | ||
| 39 | + | ||
| 40 | + //controller相关的type | ||
| 41 | + public static final String TYPE_LIVE = "live"; | ||
| 42 | + public static final String TYPE_VOD = "vod"; | ||
| 43 | + public static final String TYPE_UGC_LIVE = "ugcLive"; | ||
| 44 | + public static final String TYPE_UGC_VOD = "ugcVod"; | ||
| 45 | + | ||
| 46 | + public static final String CAN_MOBILE_NET_PLAY = "CAN_MOBILE_NET_PLAY"; | ||
| 47 | + | ||
| 48 | + //手势点下时当前播放时长 | ||
| 49 | + private long touchDownCurPosition; | ||
| 50 | + //拖动结束或拖拽进度条时需要seekTo的位置 | ||
| 51 | + private long touchSeekToPosition = 0; | ||
| 52 | + //记录当前是否是竖屏 | ||
| 53 | + private static ObservableBoolean observableIsPortrait; | ||
| 54 | + //记录当前是否是ugc节目 | ||
| 55 | + private static ObservableBoolean observableIsUgc; | ||
| 56 | + //记录当前视频高度 | ||
| 57 | + private static ObservableInt observableVideoHeight; | ||
| 58 | + //记录当前视频宽度 | ||
| 59 | + private static ObservableInt observableVideoWidth; | ||
| 60 | + //记录当前视频是否已经onError | ||
| 61 | + private boolean isPlayerError = false; | ||
| 62 | + //设置touchView 是否拦截touch事件 | ||
| 63 | + private boolean canTouch = true; | ||
| 64 | + //一进来有没有网络 | ||
| 65 | + private boolean isStartNoNet = false; | ||
| 66 | + //记录是否能手机网络播放 | ||
| 67 | + private boolean canMobilePlay = false; | ||
| 68 | + //本地缓存文件 | ||
| 69 | + private SharedPreferencesHelper sharedPreferencesHelper; | ||
| 70 | + //播放前请求的播放详情接口重试的监听回调 | ||
| 71 | + private VideoRetryListener videoRetryListener; | ||
| 72 | + | ||
| 73 | + private Handler mHandler = new Handler() { | ||
| 74 | + @Override | ||
| 75 | + public void handleMessage(Message msg) { | ||
| 76 | + super.handleMessage(msg); | ||
| 77 | + switch (msg.what) { | ||
| 78 | + case UPDATE_CONTROLLER: | ||
| 79 | + binding.controllerView.setDurProgress(binding.videoView.getDuration()); | ||
| 80 | + binding.controllerView.setCurProgress(binding.videoView.getCurrentPosition()); | ||
| 81 | + setPlayPosition(binding.videoView.getCurrentPosition()); | ||
| 82 | + startUpdateTimer(UPDATE_CONTROLLER_DELAYED); | ||
| 83 | + break; | ||
| 84 | + case HIDE_CONTROLLER: | ||
| 85 | + binding.controllerView.changeVisible(); | ||
| 86 | + break; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + } | ||
| 90 | + }; | ||
| 91 | + | ||
| 92 | + public VideoView(Context context) { | ||
| 93 | + this(context, null); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public VideoView(Context context, AttributeSet attrs) { | ||
| 97 | + this(context, attrs, 0); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public VideoView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 101 | + super(context, attrs, defStyleAttr); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Override | ||
| 105 | + protected void init() { | ||
| 106 | + super.init(); | ||
| 107 | + sharedPreferencesHelper = SharedPreferencesHelper.getInstance(getContext()); | ||
| 108 | + observableIsPortrait = new ObservableBoolean(); | ||
| 109 | + observableIsUgc = new ObservableBoolean(); | ||
| 110 | + observableVideoHeight = new ObservableInt(); | ||
| 111 | + observableVideoWidth = new ObservableInt(); | ||
| 112 | + observableVideoHeight.set((int) mContext.getResources().getDimension(R.dimen.videoPortraitHeight)); | ||
| 113 | + observableVideoWidth.set(ViewGroup.LayoutParams.MATCH_PARENT); | ||
| 114 | + observableIsPortrait.set(PlayerUtils.isPortrait(getContext())); | ||
| 115 | + binding.setVideoPortraitHeight(observableVideoHeight); | ||
| 116 | + binding.setVideoPortraitWidth(observableVideoWidth); | ||
| 117 | + binding.setIsPortrait(observableIsPortrait); | ||
| 118 | + binding.setIsUgc(observableIsUgc); | ||
| 119 | + binding.touchView.setTouchListener(this); | ||
| 120 | + binding.controllerView.setOnControllerListener(this); | ||
| 121 | + binding.infoView.setInfoListener(this); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public void setVideoInfo(VideoModel videoInfo) { | ||
| 125 | + canMobilePlay = sharedPreferencesHelper.getBoolean(CAN_MOBILE_NET_PLAY, false); | ||
| 126 | + setCanMobileNetPlay(canMobilePlay); | ||
| 127 | + | ||
| 128 | + videoModel = videoInfo; | ||
| 129 | + binding.controllerView.setTitle(videoInfo.getTitle()); | ||
| 130 | + binding.controllerView.setRateInfo(videoInfo.getRates()); | ||
| 131 | + setControllerLayout(); | ||
| 132 | + | ||
| 133 | + binding.infoView.setInfoViewLayout(observableIsUgc.get() ? PlayerInfoView.VIDEO_INFO_UGC : PlayerInfoView.VIDEO_INFO_NORMAL); | ||
| 134 | + binding.infoView.show(PlayerInfoView.SHOW_LOADING); | ||
| 135 | + | ||
| 136 | + if (NetworkUtil.isConnectInternet(getContext())) { | ||
| 137 | + isStartNoNet = false; | ||
| 138 | + setDataSource(); | ||
| 139 | + } else { | ||
| 140 | + isStartNoNet = true; | ||
| 141 | + binding.infoView.show(PlayerInfoView.SHOW_ERROR); | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + //设置请求播放详情接口失败重试的监听,只有普通直播和普通点播详情页面用到了 | ||
| 146 | + public void setVideoRetryListener(VideoRetryListener listener) { | ||
| 147 | + this.videoRetryListener = listener; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + //设置请求播放详情接口失败展示失败页面,只有普通直播和普通点播详情页面用到了 | ||
| 151 | + public void showVideoRetry() { | ||
| 152 | + if (binding.infoView != null) { | ||
| 153 | + binding.infoView.setInfoViewLayout(PlayerInfoView.VIDEO_INFO_NORMAL); | ||
| 154 | + binding.infoView.show(PlayerInfoView.SHOW_ERROR); | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + //设置一开始是否允许手机网播放视频 | ||
| 159 | + private void setCanMobileNetPlay(boolean canMobilePlay) { | ||
| 160 | + this.canMobilePlay = canMobilePlay; | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + //设置当前的网络状态,页面一接收到网络状态就设置此方法 | ||
| 164 | + public void setCurNetStatus(int curNetStatus) { | ||
| 165 | + switch (curNetStatus) { | ||
| 166 | + case NetStatusEvent.NET_DISCONNECT: | ||
| 167 | + binding.infoView.show(PlayerInfoView.SHOW_ERROR); | ||
| 168 | + break; | ||
| 169 | + case NetStatusEvent.NET_MOBILE: | ||
| 170 | + if (binding.videoView.getPlayState() && !canMobilePlay) { | ||
| 171 | + binding.infoView.show(PlayerInfoView.SHOW_MOBILE_NET); | ||
| 172 | + isPlay = false; | ||
| 173 | + setPlayState(false); | ||
| 174 | + } | ||
| 175 | + break; | ||
| 176 | + case NetStatusEvent.NET_WIFI: | ||
| 177 | + if (binding.infoView.getCurInfoType() == PlayerInfoView.SHOW_MOBILE_NET) { | ||
| 178 | + binding.infoView.show(PlayerInfoView.SHOW_NULL); | ||
| 179 | + isPlay = true; | ||
| 180 | + if (binding.videoView.getPlayState()) setPlayState(true); | ||
| 181 | + } | ||
| 182 | + break; | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + @Subscribe(threadMode = ThreadMode.MAIN) | ||
| 187 | + public void onNetStatusChange(NetStatusEvent event) { | ||
| 188 | + setCurNetStatus(event.getNetStatus()); | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + @Override | ||
| 192 | + protected void onAttachedToWindow() { | ||
| 193 | + super.onAttachedToWindow(); | ||
| 194 | + EventBus.getDefault().register(this); | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + @Override | ||
| 198 | + protected void onDetachedFromWindow() { | ||
| 199 | + super.onDetachedFromWindow(); | ||
| 200 | + EventBus.getDefault().unregister(this); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + private void setControllerLayout() { | ||
| 204 | + switch (videoModel.getType()) { | ||
| 205 | + case TYPE_VOD: | ||
| 206 | + observableIsUgc.set(false); | ||
| 207 | + isLive = false; | ||
| 208 | + binding.controllerView.setControllerLayout(observableIsPortrait.get() ? PlayerControllerView.VOD_P : PlayerControllerView.VOD_L); | ||
| 209 | + break; | ||
| 210 | + case TYPE_LIVE: | ||
| 211 | + observableIsUgc.set(false); | ||
| 212 | + isLive = true; | ||
| 213 | + binding.controllerView.setControllerLayout(observableIsPortrait.get() ? PlayerControllerView.LIVE_P : PlayerControllerView.LIVE_L); | ||
| 214 | + break; | ||
| 215 | + case TYPE_UGC_VOD: | ||
| 216 | + observableIsUgc.set(true); | ||
| 217 | + isLive = false; | ||
| 218 | + binding.controllerView.setControllerLayout(observableIsPortrait.get() ? PlayerControllerView.UGC_VOD_P : PlayerControllerView.UGC_VOD_L); | ||
| 219 | + break; | ||
| 220 | + case TYPE_UGC_LIVE: | ||
| 221 | + observableIsUgc.set(true); | ||
| 222 | + isLive = true; | ||
| 223 | + binding.controllerView.setControllerLayout(observableIsPortrait.get() ? PlayerControllerView.UGC_LIVE_P : PlayerControllerView.UGC_LIVE_L); | ||
| 224 | + break; | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * 获取infoView当前展示状态 | ||
| 230 | + * | ||
| 231 | + * @return | ||
| 232 | + */ | ||
| 233 | + public boolean videoInfoViewIsShow() { | ||
| 234 | + return binding.infoView.isShow(); | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + /** | ||
| 238 | + * 隐藏controller | ||
| 239 | + */ | ||
| 240 | + public void hideController() { | ||
| 241 | + if (binding.controllerView.isShow()) { | ||
| 242 | + cancelHideTimer(); | ||
| 243 | + binding.controllerView.changeVisible(); | ||
| 244 | + } | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + /** | ||
| 248 | + * 设置touchView 是否拦截touch事件 | ||
| 249 | + * | ||
| 250 | + * @param canTouch 默认true | ||
| 251 | + */ | ||
| 252 | + public void setTouchViewCanTouch(boolean canTouch) { | ||
| 253 | + this.canTouch = canTouch; | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + /** | ||
| 257 | + * 设置竖屏播放时播放器高度 | ||
| 258 | + * | ||
| 259 | + * @param videoHeight(传dp对应的像素值) 默认200dp | ||
| 260 | + */ | ||
| 261 | + public void setVideoHeight(int videoHeight) { | ||
| 262 | + observableVideoHeight.set(videoHeight); | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + /** | ||
| 266 | + * 设置竖屏播放时播放器宽度 | ||
| 267 | + * | ||
| 268 | + * @param videoWidth(传dp对应的像素值) 默认ViewGroup.LayoutParams.MATCH_PARENT | ||
| 269 | + */ | ||
| 270 | + public void setVideoWidth(int videoWidth) { | ||
| 271 | + observableVideoWidth.set(videoWidth); | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + public void stop() { | ||
| 275 | + binding.videoView.stop(); | ||
| 276 | + saveCurPlayPosition(); | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + /** | ||
| 280 | + * 屏幕切换 | ||
| 281 | + * | ||
| 282 | + * @param isPortrait | ||
| 283 | + */ | ||
| 284 | + public void onScreenChange(boolean isPortrait) { | ||
| 285 | + observableIsPortrait.set(isPortrait); | ||
| 286 | + setControllerLayout(); | ||
| 287 | + binding.infoView.onScreenChange(isPortrait); | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + @Override | ||
| 291 | + protected void setPlayState(boolean isPlay) { | ||
| 292 | + boolean isMobileNet = NetworkUtil.isMobileNet(getContext()); | ||
| 293 | + if (isMobileNet && isPlay) | ||
| 294 | + Toast.makeText(getContext(), getResources().getString(R.string.player_mobile_net_toast), Toast.LENGTH_LONG).show(); | ||
| 295 | + if (isPlay && !NetworkUtil.isConnectInternet(getContext())) { | ||
| 296 | + binding.infoView.show(PlayerInfoView.SHOW_ERROR); | ||
| 297 | + } else if (isPlay && !canMobilePlay && isMobileNet) { | ||
| 298 | + this.isPlay = false; | ||
| 299 | + super.setPlayState(false); | ||
| 300 | + binding.infoView.show(PlayerInfoView.SHOW_MOBILE_NET); | ||
| 301 | + } else { | ||
| 302 | + if (isPlay) binding.infoView.show(PlayerInfoView.SHOW_NULL); | ||
| 303 | + super.setPlayState(isPlay); | ||
| 304 | + } | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + @Override | ||
| 308 | + public void onDestroy() { | ||
| 309 | + super.onDestroy(); | ||
| 310 | + cancelUpdateTimer(); | ||
| 311 | + cancelHideTimer(); | ||
| 312 | + } | ||
| 313 | + | ||
| 314 | + // --------------------- touch 相关回调 start------------------------- | ||
| 315 | + @Override | ||
| 316 | + public String change_value_progress(int percent, boolean update) { | ||
| 317 | + if (update) { | ||
| 318 | + binding.videoView.seekTo(touchSeekToPosition, true); | ||
| 319 | + startUpdateTimer(1000); | ||
| 320 | + startHideTimer(HIDE_CONTROLLER_DELAYED); | ||
| 321 | + } else { | ||
| 322 | + cancelUpdateTimer(); | ||
| 323 | + cancelHideTimer(); | ||
| 324 | + touchSeekToPosition = (touchDownCurPosition + binding.videoView.getDuration() * percent / 100); | ||
| 325 | + binding.controllerView.setCurProgress(touchSeekToPosition); | ||
| 326 | + if (!binding.controllerView.isShow()) | ||
| 327 | + binding.controllerView.changeVisible(); | ||
| 328 | + } | ||
| 329 | + return ""; | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + @Override | ||
| 333 | + public void click() { | ||
| 334 | + binding.controllerView.changeVisible(); | ||
| 335 | + if (binding.controllerView.isShow()) startHideTimer(HIDE_CONTROLLER_DELAYED); | ||
| 336 | + else cancelHideTimer(); | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + @Override | ||
| 340 | + public void down() { | ||
| 341 | + touchDownCurPosition = binding.videoView.getCurrentPosition(); | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + @Override | ||
| 345 | + public boolean canTouch() { | ||
| 346 | + return videoInfoViewIsShow() ? false : canTouch; | ||
| 347 | + } | ||
| 348 | +// --------------------- touch 相关回调 end------------------------- | ||
| 349 | + | ||
| 350 | + // --------------------- controller 相关回调 start------------------------- | ||
| 351 | + @Override | ||
| 352 | + public void onControllerViewClick(int id) { | ||
| 353 | + switch (id) { | ||
| 354 | + case PlayerControllerView.ID_CLICK_PLAY_BUTTON: | ||
| 355 | + playBtnClick(); | ||
| 356 | + break; | ||
| 357 | + } | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + //播放进度手动改变开始 | ||
| 361 | + @Override | ||
| 362 | + public void onSeekProgressChange(int progress) { | ||
| 363 | + cancelUpdateTimer(); | ||
| 364 | + touchSeekToPosition = progress * 1000; | ||
| 365 | + binding.controllerView.setCurProgress(touchSeekToPosition); | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + //播放进度手动改变结束 | ||
| 369 | + @Override | ||
| 370 | + public void onSeekComplete() { | ||
| 371 | + binding.videoView.seekTo(touchSeekToPosition, true); | ||
| 372 | + startUpdateTimer(1000); | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + @Override | ||
| 376 | + public void onSwitchRate(String rate) { | ||
| 377 | + switchVideoRate(rate); | ||
| 378 | + } | ||
| 379 | +// --------------------- controller 相关回调 end------------------------- | ||
| 380 | + | ||
| 381 | + // --------------------- 播放器 相关回调 start------------------------- | ||
| 382 | + @Override | ||
| 383 | + public void onPrepared(IMediaPlayer iMediaPlayer) { | ||
| 384 | + super.onPrepared(iMediaPlayer); | ||
| 385 | + isPlayerError = false; | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + @Override | ||
| 389 | + public void onPlayState(boolean isPlay) { | ||
| 390 | + super.onPlayState(isPlay); | ||
| 391 | + if (isPlay) startUpdateTimer(0); | ||
| 392 | + else cancelUpdateTimer(); | ||
| 393 | + binding.controllerView.setIsPlay(isPlay); | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + @Override | ||
| 397 | + public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i) { | ||
| 398 | + super.onBufferingUpdate(iMediaPlayer, i); | ||
| 399 | + } | ||
| 400 | + | ||
| 401 | + @Override | ||
| 402 | + public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i1) { | ||
| 403 | + switch (i) { | ||
| 404 | + case IMediaPlayer.MEDIA_INFO_AUDIO_RENDERING_START: | ||
| 405 | + //视频开始渲染 | ||
| 406 | + break; | ||
| 407 | + case IMediaPlayer.MEDIA_INFO_BUFFERING_START: | ||
| 408 | + if (iMediaPlayer.getPlayState() && !switchingVideoRate) | ||
| 409 | + binding.infoView.show(PlayerInfoView.SHOW_BUFFERING); | ||
| 410 | + break; | ||
| 411 | + case IMediaPlayer.MEDIA_INFO_BUFFERING_END: | ||
| 412 | + if (iMediaPlayer.getPlayState()) | ||
| 413 | + binding.infoView.show(PlayerInfoView.SHOW_NULL); | ||
| 414 | + break; | ||
| 415 | + } | ||
| 416 | + return false; | ||
| 417 | + } | ||
| 418 | + | ||
| 419 | + @Override | ||
| 420 | + public boolean onError(IMediaPlayer iMediaPlayer, int i, int i1) { | ||
| 421 | + isPlayerError = true; | ||
| 422 | + //接收视讯云播放状态后,此方法还有可能会执行,因此做一下过滤 | ||
| 423 | + if (canPlay && binding.infoView.getCurInfoType() != PlayerInfoView.SHOW_ERROR) | ||
| 424 | + binding.infoView.show(PlayerInfoView.SHOW_ERROR); | ||
| 425 | + return false; | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + @Override | ||
| 429 | + public void onCompletion(IMediaPlayer iMediaPlayer) { | ||
| 430 | + super.onCompletion(iMediaPlayer); | ||
| 431 | + //非因为异常导致的结束 | ||
| 432 | + if (!isPlayerError) { | ||
| 433 | + binding.infoView.show(PlayerInfoView.SHOW_END); | ||
| 434 | + } | ||
| 435 | + } | ||
| 436 | + // --------------------- 播放器 相关回调 end------------------------- | ||
| 437 | + | ||
| 438 | + //开始更新controller 定时器 | ||
| 439 | + public void startUpdateTimer(long startTime) { | ||
| 440 | + //只有点播才有更新进度条 | ||
| 441 | + if (isLive) return; | ||
| 442 | + if (mHandler != null) { | ||
| 443 | + cancelUpdateTimer(); | ||
| 444 | + mHandler.sendEmptyMessageDelayed(UPDATE_CONTROLLER, startTime); | ||
| 445 | + } | ||
| 446 | + } | ||
| 447 | + | ||
| 448 | + //取消更新controller定时器 | ||
| 449 | + public void cancelUpdateTimer() { | ||
| 450 | + if (mHandler != null && mHandler.hasMessages(UPDATE_CONTROLLER)) | ||
| 451 | + mHandler.removeMessages(UPDATE_CONTROLLER); | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + //开始隐藏controller 定时器 | ||
| 455 | + public void startHideTimer(long startTime) { | ||
| 456 | + if (mHandler != null) { | ||
| 457 | + cancelHideTimer(); | ||
| 458 | + mHandler.sendEmptyMessageDelayed(HIDE_CONTROLLER, startTime); | ||
| 459 | + } | ||
| 460 | + } | ||
| 461 | + | ||
| 462 | + //取消隐藏controller定时器 | ||
| 463 | + public void cancelHideTimer() { | ||
| 464 | + if (mHandler != null && mHandler.hasMessages(HIDE_CONTROLLER)) | ||
| 465 | + mHandler.removeMessages(HIDE_CONTROLLER); | ||
| 466 | + } | ||
| 467 | + | ||
| 468 | + // -----------------------------info view 相关回调 start--------------------- | ||
| 469 | + @Override | ||
| 470 | + public void onInfoViewClick(int id) { | ||
| 471 | + switch (id) { | ||
| 472 | + case PlayerInfoView.ID_CLICK_INFO_REPLAY: | ||
| 473 | + replay(); | ||
| 474 | + break; | ||
| 475 | + case PlayerInfoView.ID_CLICK_INFO_RETRY: | ||
| 476 | + binding.infoView.show(PlayerInfoView.SHOW_LOADING); | ||
| 477 | + if (videoRetryListener != null && videoModel == null) { | ||
| 478 | + videoRetryListener.loadVideoInfoRetry(); | ||
| 479 | + } else { | ||
| 480 | + if (NetworkUtil.isConnectInternet(getContext())) { | ||
| 481 | + if (isStartNoNet) { | ||
| 482 | + setDataSource(); | ||
| 483 | + } else { | ||
| 484 | + retry(); | ||
| 485 | + } | ||
| 486 | + } else { | ||
| 487 | + binding.infoView.show(PlayerInfoView.SHOW_ERROR); | ||
| 488 | + } | ||
| 489 | + } | ||
| 490 | + break; | ||
| 491 | + case PlayerInfoView.ID_CLICK_INFO_MOBILE_NET_PLAY: | ||
| 492 | + sharedPreferencesHelper.setValue(CAN_MOBILE_NET_PLAY, true); | ||
| 493 | + this.isPlay = true; | ||
| 494 | + canMobilePlay = true; | ||
| 495 | + setPlayState(true); | ||
| 496 | + break; | ||
| 497 | + } | ||
| 498 | + } | ||
| 499 | +// -----------------------------info view 相关回调 end--------------------- | ||
| 500 | + | ||
| 501 | + //播放前请求详情页面失败重试的监听回调,只有普通直播和普通点播详情页面用到了 | ||
| 502 | + public interface VideoRetryListener { | ||
| 503 | + void loadVideoInfoRetry(); | ||
| 504 | + } | ||
| 505 | +} |
app/src/main/res/drawable-xhdpi/switch_thumb_dan_off.png
0 → 100644
1.34 KB
app/src/main/res/drawable-xhdpi/switch_thumb_dan_on.png
0 → 100644
1.28 KB
app/src/main/res/drawable-xxhdpi/image_error.png
0 → 100644
17.2 KB
app/src/main/res/drawable-xxhdpi/player_back.png
0 → 100644
1.19 KB
app/src/main/res/drawable-xxhdpi/player_brightness.png
0 → 100644
3.26 KB
app/src/main/res/drawable-xxhdpi/player_full_screen.png
0 → 100644
386 Bytes
app/src/main/res/drawable-xxhdpi/player_pause.png
0 → 100644
1.18 KB
app/src/main/res/drawable-xxhdpi/player_play.png
0 → 100644
945 Bytes
app/src/main/res/drawable-xxhdpi/player_volume.png
0 → 100644
3.58 KB
app/src/main/res/drawable/player_btn_bg.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:shape="rectangle" | ||
| 4 | + android:useLevel="false"> | ||
| 5 | + | ||
| 6 | + <stroke | ||
| 7 | + android:width="2dp" | ||
| 8 | + android:color="@android:color/white" /> | ||
| 9 | + | ||
| 10 | + <padding | ||
| 11 | + android:bottom="5dp" | ||
| 12 | + android:left="10dp" | ||
| 13 | + android:right="10dp" | ||
| 14 | + android:top="5dp" /> | ||
| 15 | + | ||
| 16 | + <corners | ||
| 17 | + android:bottomLeftRadius="10dp" | ||
| 18 | + android:bottomRightRadius="10dp" | ||
| 19 | + android:topLeftRadius="10dp" | ||
| 20 | + android:topRightRadius="10dp" /> <!-- 设置四个角的半径 --> | ||
| 21 | + | ||
| 22 | +</shape> | ||
| 0 | \ No newline at end of file | 23 | \ No newline at end of file |
app/src/main/res/drawable/player_rate_bg.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + <solid android:color="#99000000" /> | ||
| 7 | + | ||
| 8 | + <size | ||
| 9 | + android:height="26dp" /> | ||
| 10 | + | ||
| 11 | + <corners | ||
| 12 | + android:bottomLeftRadius="13dp" | ||
| 13 | + android:bottomRightRadius="13dp" | ||
| 14 | + android:topLeftRadius="13dp" | ||
| 15 | + android:topRightRadius="13dp" /> <!-- 设置四个角的半径 --> | ||
| 16 | + | ||
| 17 | + <stroke android:color="#99ffffff" android:width="1dp"/> | ||
| 18 | + | ||
| 19 | +</shape> | ||
| 0 | \ No newline at end of file | 20 | \ No newline at end of file |
app/src/main/res/drawable/player_volumn_bg.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + <solid android:color="#b2000000" /> | ||
| 7 | + | ||
| 8 | + <size | ||
| 9 | + android:width="109dp" | ||
| 10 | + android:height="90dp"/> | ||
| 11 | + | ||
| 12 | + <corners | ||
| 13 | + android:bottomLeftRadius="10dp" | ||
| 14 | + android:bottomRightRadius="10dp" | ||
| 15 | + android:topLeftRadius="10dp" | ||
| 16 | + android:topRightRadius="10dp" /> <!-- 设置四个角的半径 --> | ||
| 17 | + | ||
| 18 | +</shape> | ||
| 0 | \ No newline at end of file | 19 | \ No newline at end of file |
app/src/main/res/drawable/switch_thumb.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:drawable="@drawable/switch_thumb_dan_on" android:state_checked="true" /> | ||
| 4 | + <item android:drawable="@drawable/switch_thumb_dan_off" android:state_checked="false" /> | ||
| 5 | +</selector> | ||
| 0 | \ No newline at end of file | 6 | \ No newline at end of file |
app/src/main/res/drawable/switch_track.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:drawable="@drawable/switch_track_dan_on" android:state_checked="true" /> | ||
| 4 | + <item android:drawable="@drawable/switch_track_dan_off" android:state_checked="false" /> | ||
| 5 | +</selector> | ||
| 0 | \ No newline at end of file | 6 | \ No newline at end of file |
app/src/main/res/drawable/switch_track_dan_off.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <solid android:color="#CC000000" /> | ||
| 5 | + <corners android:radius="9dp" /> | ||
| 6 | + <size | ||
| 7 | + android:height="18dp" /> | ||
| 8 | + <stroke | ||
| 9 | + android:width="1dp" | ||
| 10 | + android:color="#33000000" /> | ||
| 11 | +</shape> | ||
| 0 | \ No newline at end of file | 12 | \ No newline at end of file |
app/src/main/res/drawable/switch_track_dan_on.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <solid android:color="#FF4E51" /> | ||
| 5 | + <corners android:radius="9dp" /> | ||
| 6 | + <size | ||
| 7 | + android:height="18dp" /> | ||
| 8 | + <stroke | ||
| 9 | + android:width="1dp" | ||
| 10 | + android:color="#33FF4E51" /> | ||
| 11 | +</shape> | ||
| 0 | \ No newline at end of file | 12 | \ No newline at end of file |
app/src/main/res/layout/activity_player.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent" > | ||
| 5 | + | ||
| 6 | + <RelativeLayout | ||
| 7 | + android:id="@+id/fragmentContainer" | ||
| 8 | + android:layout_width="match_parent" | ||
| 9 | + android:layout_height="match_parent"/> | ||
| 10 | + | ||
| 11 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 12 | \ No newline at end of file |
app/src/main/res/layout/fragment_active_list.xml
0 → 100644
| 1 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter"/> | ||
| 6 | + <import type="android.support.v7.widget.LinearLayoutManager"/> | ||
| 7 | + | ||
| 8 | + <variable | ||
| 9 | + name="layoutManager" | ||
| 10 | + type="LinearLayoutManager" /> | ||
| 11 | + | ||
| 12 | + <variable | ||
| 13 | + name="listAdapter" | ||
| 14 | + type="DataBindingAdapter" /> | ||
| 15 | + </data> | ||
| 16 | + | ||
| 17 | + <RelativeLayout | ||
| 18 | + android:layout_width="match_parent" | ||
| 19 | + android:layout_height="match_parent" | ||
| 20 | + android:fitsSystemWindows="true"> | ||
| 21 | + | ||
| 22 | + <android.support.v4.widget.SwipeRefreshLayout | ||
| 23 | + android:id="@+id/contentView" | ||
| 24 | + android:layout_width="match_parent" | ||
| 25 | + android:layout_height="match_parent"> | ||
| 26 | + | ||
| 27 | + <android.support.v7.widget.RecyclerView | ||
| 28 | + android:id="@+id/recyclerView" | ||
| 29 | + android:layout_width="match_parent" | ||
| 30 | + android:layout_height="match_parent" | ||
| 31 | + app:adapter="@{listAdapter}" | ||
| 32 | + app:layoutManager="@{layoutManager}"/> | ||
| 33 | + | ||
| 34 | + </android.support.v4.widget.SwipeRefreshLayout> | ||
| 35 | + | ||
| 36 | + </RelativeLayout> | ||
| 37 | +</layout> |
app/src/main/res/layout/fragment_live.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + | ||
| 7 | + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter"/> | ||
| 8 | + <import type="android.support.v7.widget.LinearLayoutManager"/> | ||
| 9 | + | ||
| 10 | + <variable | ||
| 11 | + name="listAdapter" | ||
| 12 | + type="DataBindingAdapter"/> | ||
| 13 | + | ||
| 14 | + <variable | ||
| 15 | + name="layoutManager" | ||
| 16 | + type="LinearLayoutManager"/> | ||
| 17 | + | ||
| 18 | + </data> | ||
| 19 | + | ||
| 20 | + <RelativeLayout | ||
| 21 | + android:layout_width="match_parent" | ||
| 22 | + android:layout_height="match_parent"> | ||
| 23 | + | ||
| 24 | + <android.support.v7.widget.RecyclerView | ||
| 25 | + android:id="@+id/recyclerView" | ||
| 26 | + android:layout_width="match_parent" | ||
| 27 | + android:layout_height="match_parent" | ||
| 28 | + app:adapter="@{listAdapter}" | ||
| 29 | + app:layoutManager="@{layoutManager}"/> | ||
| 30 | + | ||
| 31 | + </RelativeLayout> | ||
| 32 | + | ||
| 33 | +</layout> | ||
| 0 | \ No newline at end of file | 34 | \ No newline at end of file |
app/src/main/res/layout/fragment_player_live.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + </data> | ||
| 7 | + | ||
| 8 | + <RelativeLayout | ||
| 9 | + android:layout_width="match_parent" | ||
| 10 | + android:layout_height="match_parent"> | ||
| 11 | + | ||
| 12 | + <com.cnlive.gundam.video.view.VideoView | ||
| 13 | + android:id="@+id/videoView" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="wrap_content" /> | ||
| 16 | + | ||
| 17 | + <com.cnlive.libs.video.barrage.BarrageLayout | ||
| 18 | + android:id="@+id/private_message" | ||
| 19 | + android:layout_width="match_parent" | ||
| 20 | + android:layout_height="wrap_content" /> | ||
| 21 | + | ||
| 22 | + <RelativeLayout | ||
| 23 | + android:id="@+id/contentLayout" | ||
| 24 | + android:background="@android:color/black" | ||
| 25 | + android:layout_width="match_parent" | ||
| 26 | + android:layout_height="match_parent" | ||
| 27 | + android:layout_below="@+id/videoView"> | ||
| 28 | + | ||
| 29 | + </RelativeLayout> | ||
| 30 | + | ||
| 31 | + </RelativeLayout> | ||
| 32 | + | ||
| 33 | +</layout> | ||
| 0 | \ No newline at end of file | 34 | \ No newline at end of file |
app/src/main/res/layout/fragment_player_ugc_live.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + </data> | ||
| 7 | + | ||
| 8 | + <RelativeLayout | ||
| 9 | + android:layout_width="match_parent" | ||
| 10 | + android:layout_height="match_parent"> | ||
| 11 | + | ||
| 12 | + <com.cnlive.gundam.video.view.VideoView | ||
| 13 | + android:id="@+id/videoView" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="match_parent"/> | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + <com.cnlive.libs.video.barrage.BarrageLayout | ||
| 19 | + android:id="@+id/private_message" | ||
| 20 | + android:layout_width="match_parent" | ||
| 21 | + android:layout_height="wrap_content"/> | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + <RelativeLayout | ||
| 25 | + android:id="@+id/contentLayout" | ||
| 26 | + android:background="@android:color/black" | ||
| 27 | + android:layout_width="match_parent" | ||
| 28 | + android:layout_height="400dp" | ||
| 29 | + android:layout_alignParentBottom="true"> | ||
| 30 | + | ||
| 31 | + </RelativeLayout> | ||
| 32 | + | ||
| 33 | + </RelativeLayout> | ||
| 34 | + | ||
| 35 | +</layout> | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
app/src/main/res/layout/fragment_player_ugc_vod.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + </data> | ||
| 7 | + | ||
| 8 | + <RelativeLayout | ||
| 9 | + android:layout_width="match_parent" | ||
| 10 | + android:layout_height="match_parent"> | ||
| 11 | + | ||
| 12 | + <com.cnlive.gundam.video.view.VideoView | ||
| 13 | + android:id="@+id/videoView" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="match_parent" /> | ||
| 16 | + | ||
| 17 | + <RelativeLayout | ||
| 18 | + android:id="@+id/contentLayout" | ||
| 19 | + android:layout_width="match_parent" | ||
| 20 | + android:layout_height="match_parent"> | ||
| 21 | + | ||
| 22 | + </RelativeLayout> | ||
| 23 | + | ||
| 24 | + </RelativeLayout> | ||
| 25 | + | ||
| 26 | +</layout> | ||
| 0 | \ No newline at end of file | 27 | \ No newline at end of file |
app/src/main/res/layout/fragment_player_vod.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + </data> | ||
| 7 | + | ||
| 8 | + <RelativeLayout | ||
| 9 | + android:layout_width="match_parent" | ||
| 10 | + android:layout_height="match_parent"> | ||
| 11 | + | ||
| 12 | + <com.cnlive.gundam.video.view.VideoView | ||
| 13 | + android:id="@+id/videoView" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="wrap_content" /> | ||
| 16 | + <FrameLayout | ||
| 17 | + android:layout_below="@+id/videoView" | ||
| 18 | + android:layout_width="match_parent" | ||
| 19 | + android:layout_height="match_parent" | ||
| 20 | + android:id="@+id/fl_vod"></FrameLayout> | ||
| 21 | + | ||
| 22 | + </RelativeLayout> | ||
| 23 | + | ||
| 24 | +</layout> | ||
| 0 | \ No newline at end of file | 25 | \ No newline at end of file |
app/src/main/res/layout/layout_item_active_video_list.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + | ||
| 7 | + <import type="com.cnlive.gundam.main.model.VideoListProgram" /> | ||
| 8 | + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/> | ||
| 9 | + | ||
| 10 | + <variable | ||
| 11 | + name="program" | ||
| 12 | + type="VideoListProgram" /> | ||
| 13 | + | ||
| 14 | + <variable | ||
| 15 | + name="viewClickListner" | ||
| 16 | + type="OnAdapterViewClickListener<VideoListProgram>"/> | ||
| 17 | + | ||
| 18 | + </data> | ||
| 19 | + | ||
| 20 | + <RelativeLayout | ||
| 21 | + android:id="@+id/itemLayout" | ||
| 22 | + android:layout_width="match_parent" | ||
| 23 | + android:layout_height="wrap_content" | ||
| 24 | + android:onClick="@{(view)->viewClickListner.onViewClick(view,program)}"> | ||
| 25 | + | ||
| 26 | + <ImageView | ||
| 27 | + android:id="@+id/image" | ||
| 28 | + android:layout_width="match_parent" | ||
| 29 | + android:layout_height="200dp" | ||
| 30 | + android:scaleType="centerCrop" | ||
| 31 | + app:error="@{@drawable/image_error}" | ||
| 32 | + app:imageUrl="@{program.getImg()}" /> | ||
| 33 | + | ||
| 34 | + <TextView | ||
| 35 | + android:id="@+id/title" | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="wrap_content" | ||
| 38 | + android:layout_below="@+id/image" | ||
| 39 | + android:padding="10dp" | ||
| 40 | + android:text="@{program.getTitle()}" | ||
| 41 | + android:textColor="@android:color/black" | ||
| 42 | + android:textSize="16sp"/> | ||
| 43 | + | ||
| 44 | + <View | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="8dp" | ||
| 47 | + android:layout_below="@+id/title" | ||
| 48 | + android:background="@color/list_divider" /> | ||
| 49 | + | ||
| 50 | + </RelativeLayout> | ||
| 51 | + | ||
| 52 | +</layout> | ||
| 0 | \ No newline at end of file | 53 | \ No newline at end of file |
app/src/main/res/layout/layout_item_video_list.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + | ||
| 7 | + <import type="com.cnlive.gundam.main.model.VideoListProgram" /> | ||
| 8 | + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/> | ||
| 9 | + | ||
| 10 | + <variable | ||
| 11 | + name="program" | ||
| 12 | + type="VideoListProgram" /> | ||
| 13 | + | ||
| 14 | + <variable | ||
| 15 | + name="viewClickListner" | ||
| 16 | + type="OnAdapterViewClickListener<VideoListProgram>"/> | ||
| 17 | + | ||
| 18 | + </data> | ||
| 19 | + | ||
| 20 | + <RelativeLayout | ||
| 21 | + android:id="@+id/itemLayout" | ||
| 22 | + android:layout_width="match_parent" | ||
| 23 | + android:layout_height="wrap_content" | ||
| 24 | + android:onClick="@{(view)->viewClickListner.onViewClick(view,program)}"> | ||
| 25 | + | ||
| 26 | + <ImageView | ||
| 27 | + android:id="@+id/image" | ||
| 28 | + android:layout_width="match_parent" | ||
| 29 | + android:layout_height="200dp" | ||
| 30 | + android:scaleType="centerCrop" | ||
| 31 | + app:error="@{@drawable/image_error}" | ||
| 32 | + app:imageUrl="@{program.getImg()}" /> | ||
| 33 | + | ||
| 34 | + <TextView | ||
| 35 | + android:id="@+id/title" | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="wrap_content" | ||
| 38 | + android:layout_below="@+id/image" | ||
| 39 | + android:padding="10dp" | ||
| 40 | + android:text="@{program.getTitle()}" | ||
| 41 | + android:textColor="@android:color/black" | ||
| 42 | + android:textSize="16sp"/> | ||
| 43 | + | ||
| 44 | + <View | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="8dp" | ||
| 47 | + android:layout_below="@+id/title" | ||
| 48 | + android:background="@color/list_divider" /> | ||
| 49 | + | ||
| 50 | + </RelativeLayout> | ||
| 51 | + | ||
| 52 | +</layout> | ||
| 0 | \ No newline at end of file | 53 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_live_l.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + | ||
| 7 | + <import type="android.databinding.ObservableField" /> | ||
| 8 | + | ||
| 9 | + <import type="android.databinding.ObservableBoolean" /> | ||
| 10 | + | ||
| 11 | + <import type="android.databinding.ObservableInt" /> | ||
| 12 | + | ||
| 13 | + <import type="com.cnlive.gundam.video.utils.VideoRateUtil" /> | ||
| 14 | + | ||
| 15 | + <import type="android.view.View" /> | ||
| 16 | + | ||
| 17 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView" /> | ||
| 18 | + | ||
| 19 | + <variable | ||
| 20 | + name="title" | ||
| 21 | + type="ObservableField<String>" /> | ||
| 22 | + | ||
| 23 | + <variable | ||
| 24 | + name="showController" | ||
| 25 | + type="ObservableBoolean" /> | ||
| 26 | + | ||
| 27 | + <variable | ||
| 28 | + name="isPlay" | ||
| 29 | + type="ObservableBoolean" /> | ||
| 30 | + | ||
| 31 | + <variable | ||
| 32 | + name="rateType" | ||
| 33 | + type="ObservableInt" /> | ||
| 34 | + | ||
| 35 | + <variable | ||
| 36 | + name="hasRate" | ||
| 37 | + type="ObservableBoolean" /> | ||
| 38 | + | ||
| 39 | + <variable | ||
| 40 | + name="showRateListLayout" | ||
| 41 | + type="ObservableBoolean" /> | ||
| 42 | + | ||
| 43 | + <variable | ||
| 44 | + name="showRateToastLayout" | ||
| 45 | + type="ObservableBoolean" /> | ||
| 46 | + | ||
| 47 | + <variable | ||
| 48 | + name="curSwitchRateType" | ||
| 49 | + type="ObservableInt" /> | ||
| 50 | + | ||
| 51 | + <variable | ||
| 52 | + name="curSwitchRateStr" | ||
| 53 | + type="ObservableField<String>" /> | ||
| 54 | + | ||
| 55 | + <variable | ||
| 56 | + name="rateListStr" | ||
| 57 | + type="ObservableField<String>" /> | ||
| 58 | + | ||
| 59 | + <variable | ||
| 60 | + name="playerControllerView" | ||
| 61 | + type="PlayerControllerView" /> | ||
| 62 | + | ||
| 63 | + </data> | ||
| 64 | + | ||
| 65 | + <RelativeLayout | ||
| 66 | + android:layout_width="match_parent" | ||
| 67 | + android:layout_height="match_parent"> | ||
| 68 | + | ||
| 69 | + <RelativeLayout | ||
| 70 | + android:id="@+id/topLayout" | ||
| 71 | + android:layout_width="match_parent" | ||
| 72 | + android:layout_height="wrap_content" | ||
| 73 | + android:background="#44000000" | ||
| 74 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 75 | + | ||
| 76 | + <ImageView | ||
| 77 | + android:id="@+id/back" | ||
| 78 | + android:layout_width="30dp" | ||
| 79 | + android:layout_height="30dp" | ||
| 80 | + android:layout_marginLeft="10dp" | ||
| 81 | + android:onClick="@{playerControllerView.onClick}" | ||
| 82 | + android:src="@drawable/player_back" /> | ||
| 83 | + | ||
| 84 | + <TextView | ||
| 85 | + android:id="@+id/title" | ||
| 86 | + android:layout_width="wrap_content" | ||
| 87 | + android:layout_height="30dp" | ||
| 88 | + android:layout_marginLeft="50dp" | ||
| 89 | + android:gravity="center" | ||
| 90 | + android:text="@{title.get()}" | ||
| 91 | + android:textColor="@android:color/white" /> | ||
| 92 | + | ||
| 93 | + </RelativeLayout> | ||
| 94 | + | ||
| 95 | + <LinearLayout | ||
| 96 | + android:layout_width="match_parent" | ||
| 97 | + android:layout_height="wrap_content" | ||
| 98 | + android:layout_alignParentBottom="true" | ||
| 99 | + android:orientation="vertical"> | ||
| 100 | + | ||
| 101 | + <RelativeLayout | ||
| 102 | + android:id="@+id/switchVideoRateToastLayout" | ||
| 103 | + android:layout_width="wrap_content" | ||
| 104 | + android:layout_height="wrap_content" | ||
| 105 | + android:layout_above="@+id/bottomLayout" | ||
| 106 | + android:background="@drawable/player_rate_bg" | ||
| 107 | + android:paddingLeft="10dp" | ||
| 108 | + android:paddingRight="10dp" | ||
| 109 | + android:layout_marginBottom="10dp" | ||
| 110 | + android:layout_marginLeft="10dp" | ||
| 111 | + android:visibility="@{showRateToastLayout.get() ? View.VISIBLE : View.GONE}"> | ||
| 112 | + | ||
| 113 | + <TextView | ||
| 114 | + android:id="@+id/toastPre" | ||
| 115 | + android:layout_width="wrap_content" | ||
| 116 | + android:layout_height="wrap_content" | ||
| 117 | + android:layout_centerVertical="true" | ||
| 118 | + android:textColor="@android:color/white" | ||
| 119 | + android:textSize="12sp" | ||
| 120 | + android:text="@{curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_START ? @string/loading_rate_pre : (curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_FINISH ? @string/loaded_rate_pre : @string/loaded_rate_error_pre)}" /> | ||
| 121 | + | ||
| 122 | + <TextView | ||
| 123 | + android:id="@+id/toastText" | ||
| 124 | + android:layout_width="wrap_content" | ||
| 125 | + android:layout_height="wrap_content" | ||
| 126 | + android:layout_centerVertical="true" | ||
| 127 | + android:layout_toRightOf="@+id/toastPre" | ||
| 128 | + android:textColor="@color/rate_sel" | ||
| 129 | + android:textSize="12sp" | ||
| 130 | + android:text="@{curSwitchRateStr.get()}" /> | ||
| 131 | + | ||
| 132 | + <TextView | ||
| 133 | + android:id="@+id/toastLast" | ||
| 134 | + android:layout_width="wrap_content" | ||
| 135 | + android:layout_height="wrap_content" | ||
| 136 | + android:layout_centerVertical="true" | ||
| 137 | + android:layout_toRightOf="@+id/toastText" | ||
| 138 | + android:textColor="@android:color/white" | ||
| 139 | + android:textSize="12sp" | ||
| 140 | + android:text="@{curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_START ? @string/loading_rate_last : (curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_FINISH ? @string/loaded_rate_last : @string/loaded_rate_error_last)}" /> | ||
| 141 | + | ||
| 142 | + </RelativeLayout> | ||
| 143 | + | ||
| 144 | + <RelativeLayout | ||
| 145 | + android:id="@+id/bottomLayout" | ||
| 146 | + android:layout_width="match_parent" | ||
| 147 | + android:layout_height="wrap_content" | ||
| 148 | + android:background="#44000000" | ||
| 149 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 150 | + | ||
| 151 | + <ImageView | ||
| 152 | + android:id="@+id/playBtn" | ||
| 153 | + android:layout_width="30dp" | ||
| 154 | + android:layout_height="30dp" | ||
| 155 | + android:layout_marginRight="5dp" | ||
| 156 | + android:onClick="@{playerControllerView.onClick}" | ||
| 157 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> | ||
| 158 | + | ||
| 159 | + <TextView | ||
| 160 | + android:id="@+id/rate" | ||
| 161 | + android:layout_width="wrap_content" | ||
| 162 | + android:layout_height="wrap_content" | ||
| 163 | + android:layout_alignParentRight="true" | ||
| 164 | + android:layout_centerVertical="true" | ||
| 165 | + android:layout_marginRight="10dp" | ||
| 166 | + android:onClick="@{playerControllerView.onClick}" | ||
| 167 | + android:text="@{VideoRateUtil.getRateText(rateType.get())}" | ||
| 168 | + android:textColor="@android:color/white" | ||
| 169 | + android:visibility="@{hasRate.get() ? View.VISIBLE : View.GONE}" /> | ||
| 170 | + | ||
| 171 | + <android.support.v7.widget.SwitchCompat | ||
| 172 | + android:id="@+id/barrage_top" | ||
| 173 | + android:layout_width="wrap_content" | ||
| 174 | + android:layout_height="wrap_content" | ||
| 175 | + android:layout_centerVertical="true" | ||
| 176 | + android:background="@null" | ||
| 177 | + android:textIsSelectable="false" | ||
| 178 | + android:layout_alignParentRight="true" | ||
| 179 | + android:thumb="@drawable/switch_thumb" | ||
| 180 | + app:switchMinWidth="30dp" | ||
| 181 | + app:track="@drawable/switch_track" /> | ||
| 182 | + | ||
| 183 | + </RelativeLayout> | ||
| 184 | + | ||
| 185 | + </LinearLayout> | ||
| 186 | + | ||
| 187 | + <RelativeLayout | ||
| 188 | + android:id="@+id/rateLayout" | ||
| 189 | + android:layout_width="match_parent" | ||
| 190 | + android:layout_height="match_parent" | ||
| 191 | + android:visibility="@{showRateListLayout.get() ? View.VISIBLE : View.GONE}"> | ||
| 192 | + | ||
| 193 | + <View | ||
| 194 | + android:id="@+id/rateOutClickView" | ||
| 195 | + android:layout_width="match_parent" | ||
| 196 | + android:layout_height="match_parent" | ||
| 197 | + android:layout_toLeftOf="@+id/rightLayout" | ||
| 198 | + android:onClick="@{playerControllerView.onClick}" /> | ||
| 199 | + | ||
| 200 | + <LinearLayout | ||
| 201 | + android:id="@+id/rightLayout" | ||
| 202 | + android:layout_width="124dp" | ||
| 203 | + android:layout_height="match_parent" | ||
| 204 | + android:layout_alignParentRight="true" | ||
| 205 | + android:background="#4c000000" | ||
| 206 | + android:gravity="center_horizontal" | ||
| 207 | + android:orientation="vertical"> | ||
| 208 | + | ||
| 209 | + <LinearLayout | ||
| 210 | + android:layout_width="wrap_content" | ||
| 211 | + android:layout_height="wrap_content" | ||
| 212 | + android:layout_weight="1" | ||
| 213 | + android:gravity="center" | ||
| 214 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_L) ? View.VISIBLE : View.GONE}"> | ||
| 215 | + | ||
| 216 | + <TextView | ||
| 217 | + android:id="@+id/rateL" | ||
| 218 | + android:layout_width="wrap_content" | ||
| 219 | + android:layout_height="wrap_content" | ||
| 220 | + android:button="@null" | ||
| 221 | + android:gravity="center" | ||
| 222 | + android:onClick="@{playerControllerView.onClick}" | ||
| 223 | + android:paddingBottom="5dp" | ||
| 224 | + android:paddingLeft="10dp" | ||
| 225 | + android:paddingRight="10dp" | ||
| 226 | + android:paddingTop="5dp" | ||
| 227 | + android:text="流畅" | ||
| 228 | + android:textColor="@{rateType == PlayerControllerView.RATE_L ? @color/rate_sel : @color/rate_nor}" | ||
| 229 | + android:textSize="17sp" /> | ||
| 230 | + </LinearLayout> | ||
| 231 | + | ||
| 232 | + | ||
| 233 | + <LinearLayout | ||
| 234 | + android:layout_width="wrap_content" | ||
| 235 | + android:layout_height="wrap_content" | ||
| 236 | + android:layout_weight="1" | ||
| 237 | + android:gravity="center" | ||
| 238 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_M) ? View.VISIBLE : View.GONE}"> | ||
| 239 | + | ||
| 240 | + <TextView | ||
| 241 | + android:id="@+id/rateM" | ||
| 242 | + android:layout_width="wrap_content" | ||
| 243 | + android:layout_height="wrap_content" | ||
| 244 | + android:button="@null" | ||
| 245 | + android:gravity="center" | ||
| 246 | + android:onClick="@{playerControllerView.onClick}" | ||
| 247 | + android:paddingBottom="5dp" | ||
| 248 | + android:paddingLeft="10dp" | ||
| 249 | + android:paddingRight="10dp" | ||
| 250 | + android:paddingTop="5dp" | ||
| 251 | + android:text="标清" | ||
| 252 | + android:textColor="@{rateType == PlayerControllerView.RATE_M ? @color/rate_sel : @color/rate_nor}" | ||
| 253 | + android:textSize="17sp" /> | ||
| 254 | + </LinearLayout> | ||
| 255 | + | ||
| 256 | + <LinearLayout | ||
| 257 | + android:layout_width="wrap_content" | ||
| 258 | + android:layout_height="wrap_content" | ||
| 259 | + android:layout_weight="1" | ||
| 260 | + android:gravity="center" | ||
| 261 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_H) ? View.VISIBLE : View.GONE}"> | ||
| 262 | + | ||
| 263 | + <TextView | ||
| 264 | + android:id="@+id/rateH" | ||
| 265 | + android:layout_width="wrap_content" | ||
| 266 | + android:layout_height="wrap_content" | ||
| 267 | + android:button="@null" | ||
| 268 | + android:gravity="center" | ||
| 269 | + android:onClick="@{playerControllerView.onClick}" | ||
| 270 | + android:paddingBottom="5dp" | ||
| 271 | + android:paddingLeft="10dp" | ||
| 272 | + android:paddingRight="10dp" | ||
| 273 | + android:paddingTop="5dp" | ||
| 274 | + android:text="高清" | ||
| 275 | + android:textColor="@{rateType == PlayerControllerView.RATE_H ? @color/rate_sel : @color/rate_nor}" | ||
| 276 | + android:textSize="17sp" /> | ||
| 277 | + </LinearLayout> | ||
| 278 | + | ||
| 279 | + <LinearLayout | ||
| 280 | + android:layout_width="wrap_content" | ||
| 281 | + android:layout_height="wrap_content" | ||
| 282 | + android:layout_weight="1" | ||
| 283 | + android:gravity="center" | ||
| 284 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_HH) ? View.VISIBLE : View.GONE}"> | ||
| 285 | + | ||
| 286 | + <TextView | ||
| 287 | + android:id="@+id/rateHH" | ||
| 288 | + android:layout_width="wrap_content" | ||
| 289 | + android:layout_height="wrap_content" | ||
| 290 | + android:button="@null" | ||
| 291 | + android:gravity="center" | ||
| 292 | + android:onClick="@{playerControllerView.onClick}" | ||
| 293 | + android:paddingBottom="5dp" | ||
| 294 | + android:paddingLeft="10dp" | ||
| 295 | + android:paddingRight="10dp" | ||
| 296 | + android:paddingTop="5dp" | ||
| 297 | + android:text="超高清" | ||
| 298 | + android:textColor="@{rateType == PlayerControllerView.RATE_HH ? @color/rate_sel : @color/rate_nor}" | ||
| 299 | + android:textSize="17sp" /> | ||
| 300 | + </LinearLayout> | ||
| 301 | + | ||
| 302 | + </LinearLayout> | ||
| 303 | + | ||
| 304 | + </RelativeLayout> | ||
| 305 | + | ||
| 306 | + </RelativeLayout> | ||
| 307 | + | ||
| 308 | +</layout> | ||
| 0 | \ No newline at end of file | 309 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_live_p.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + | ||
| 7 | + <import type="android.databinding.ObservableField"/> | ||
| 8 | + <import type="android.databinding.ObservableBoolean"/> | ||
| 9 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | ||
| 10 | + <import type="android.view.View"/> | ||
| 11 | + | ||
| 12 | + <variable | ||
| 13 | + name="title" | ||
| 14 | + type="ObservableField<String>"/> | ||
| 15 | + | ||
| 16 | + <variable | ||
| 17 | + name="showController" | ||
| 18 | + type="ObservableBoolean"/> | ||
| 19 | + | ||
| 20 | + <variable | ||
| 21 | + name="isPlay" | ||
| 22 | + type="ObservableBoolean"/> | ||
| 23 | + | ||
| 24 | + <variable | ||
| 25 | + name="playerControllerView" | ||
| 26 | + type="PlayerControllerView"/> | ||
| 27 | + | ||
| 28 | + </data> | ||
| 29 | + | ||
| 30 | + <RelativeLayout | ||
| 31 | + android:layout_width="match_parent" | ||
| 32 | + android:layout_height="match_parent"> | ||
| 33 | + | ||
| 34 | + <RelativeLayout | ||
| 35 | + android:id="@+id/topLayout" | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="wrap_content" | ||
| 38 | + android:background="#44000000" | ||
| 39 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 40 | + | ||
| 41 | + <TextView | ||
| 42 | + android:id="@+id/title" | ||
| 43 | + android:layout_width="wrap_content" | ||
| 44 | + android:layout_height="30dp" | ||
| 45 | + android:layout_marginLeft="50dp" | ||
| 46 | + android:gravity="center" | ||
| 47 | + android:textColor="@android:color/white" | ||
| 48 | + android:text="@{title.get()}" /> | ||
| 49 | + | ||
| 50 | + </RelativeLayout> | ||
| 51 | + | ||
| 52 | + <RelativeLayout | ||
| 53 | + android:id="@+id/bottomLayout" | ||
| 54 | + android:layout_width="match_parent" | ||
| 55 | + android:layout_height="wrap_content" | ||
| 56 | + android:background="#44000000" | ||
| 57 | + android:layout_alignParentBottom="true" | ||
| 58 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 59 | + | ||
| 60 | + <ImageView | ||
| 61 | + android:id="@+id/playBtn" | ||
| 62 | + android:layout_width="30dp" | ||
| 63 | + android:layout_height="30dp" | ||
| 64 | + android:layout_marginRight="5dp" | ||
| 65 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" | ||
| 66 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + <ImageView | ||
| 71 | + android:id="@+id/fullScreen" | ||
| 72 | + android:layout_width="30dp" | ||
| 73 | + android:layout_height="30dp" | ||
| 74 | + android:src="@drawable/player_full_screen" | ||
| 75 | + android:layout_alignParentRight="true" | ||
| 76 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 77 | + | ||
| 78 | + </RelativeLayout> | ||
| 79 | + | ||
| 80 | + <ImageView | ||
| 81 | + android:id="@+id/back" | ||
| 82 | + android:layout_width="30dp" | ||
| 83 | + android:layout_height="30dp" | ||
| 84 | + android:src="@drawable/player_back" | ||
| 85 | + android:layout_marginLeft="10dp" | ||
| 86 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 87 | + | ||
| 88 | + </RelativeLayout> | ||
| 89 | + | ||
| 90 | +</layout> | ||
| 0 | \ No newline at end of file | 91 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_ugc_live_l.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | + > | ||
| 5 | + | ||
| 6 | + <data> | ||
| 7 | + | ||
| 8 | + <import type="android.databinding.ObservableField" /> | ||
| 9 | + | ||
| 10 | + <import type="android.databinding.ObservableBoolean" /> | ||
| 11 | + | ||
| 12 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | ||
| 13 | + | ||
| 14 | + <import type="android.view.View" /> | ||
| 15 | + | ||
| 16 | + <variable | ||
| 17 | + name="title" | ||
| 18 | + type="ObservableField<String>" /> | ||
| 19 | + | ||
| 20 | + <variable | ||
| 21 | + name="showController" | ||
| 22 | + type="ObservableBoolean" /> | ||
| 23 | + | ||
| 24 | + <variable | ||
| 25 | + name="isPlay" | ||
| 26 | + type="ObservableBoolean" /> | ||
| 27 | + | ||
| 28 | + <variable | ||
| 29 | + name="playerControllerView" | ||
| 30 | + type="PlayerControllerView"/> | ||
| 31 | + | ||
| 32 | + </data> | ||
| 33 | + | ||
| 34 | + <RelativeLayout | ||
| 35 | + android:layout_width="match_parent" | ||
| 36 | + android:layout_height="match_parent"> | ||
| 37 | + | ||
| 38 | + <RelativeLayout | ||
| 39 | + android:id="@+id/topLayout" | ||
| 40 | + android:layout_width="match_parent" | ||
| 41 | + android:layout_height="wrap_content" | ||
| 42 | + android:background="#44000000" | ||
| 43 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 44 | + | ||
| 45 | + <ImageView | ||
| 46 | + android:id="@+id/back" | ||
| 47 | + android:layout_width="30dp" | ||
| 48 | + android:layout_height="30dp" | ||
| 49 | + android:layout_marginLeft="10dp" | ||
| 50 | + android:src="@drawable/player_back" | ||
| 51 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 52 | + | ||
| 53 | + <TextView | ||
| 54 | + android:id="@+id/title" | ||
| 55 | + android:layout_width="wrap_content" | ||
| 56 | + android:layout_height="30dp" | ||
| 57 | + android:layout_marginLeft="50dp" | ||
| 58 | + android:gravity="center" | ||
| 59 | + android:text="@{title.get()}" | ||
| 60 | + android:textColor="@android:color/white" /> | ||
| 61 | + | ||
| 62 | + </RelativeLayout> | ||
| 63 | + | ||
| 64 | + <RelativeLayout | ||
| 65 | + android:id="@+id/bottomLayout" | ||
| 66 | + android:layout_width="match_parent" | ||
| 67 | + android:layout_height="wrap_content" | ||
| 68 | + android:layout_alignParentBottom="true" | ||
| 69 | + android:background="#44000000" | ||
| 70 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 71 | + | ||
| 72 | + <ImageView | ||
| 73 | + android:id="@+id/playBtn" | ||
| 74 | + android:layout_width="30dp" | ||
| 75 | + android:layout_height="30dp" | ||
| 76 | + android:layout_marginRight="5dp" | ||
| 77 | + android:onClick="@{playerControllerView.onClick}" | ||
| 78 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + <android.support.v7.widget.SwitchCompat | ||
| 82 | + android:id="@+id/barrage_top" | ||
| 83 | + android:layout_marginRight="50dp" | ||
| 84 | + android:layout_width="wrap_content" | ||
| 85 | + android:layout_height="wrap_content" | ||
| 86 | + android:layout_centerVertical="true" | ||
| 87 | + android:background="@null" | ||
| 88 | + android:textIsSelectable="false" | ||
| 89 | + android:layout_alignParentRight="true" | ||
| 90 | + android:thumb="@drawable/switch_thumb" | ||
| 91 | + app:switchMinWidth="30dp" | ||
| 92 | + app:track="@drawable/switch_track" /> | ||
| 93 | + | ||
| 94 | + </RelativeLayout> | ||
| 95 | + | ||
| 96 | + </RelativeLayout> | ||
| 97 | + | ||
| 98 | +</layout> | ||
| 0 | \ No newline at end of file | 99 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_ugc_live_p.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | + > | ||
| 5 | + | ||
| 6 | + <data> | ||
| 7 | + | ||
| 8 | + <import type="android.databinding.ObservableField"/> | ||
| 9 | + <import type="android.databinding.ObservableBoolean"/> | ||
| 10 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | ||
| 11 | + <import type="android.view.View"/> | ||
| 12 | + | ||
| 13 | + <variable | ||
| 14 | + name="title" | ||
| 15 | + type="ObservableField<String>"/> | ||
| 16 | + | ||
| 17 | + <variable | ||
| 18 | + name="showController" | ||
| 19 | + type="ObservableBoolean"/> | ||
| 20 | + | ||
| 21 | + <variable | ||
| 22 | + name="isPlay" | ||
| 23 | + type="ObservableBoolean"/> | ||
| 24 | + | ||
| 25 | + <variable | ||
| 26 | + name="playerControllerView" | ||
| 27 | + type="PlayerControllerView"/> | ||
| 28 | + | ||
| 29 | + </data> | ||
| 30 | + | ||
| 31 | + <RelativeLayout | ||
| 32 | + android:layout_width="match_parent" | ||
| 33 | + android:layout_height="match_parent"> | ||
| 34 | + | ||
| 35 | + <RelativeLayout | ||
| 36 | + android:id="@+id/topLayout" | ||
| 37 | + android:layout_width="match_parent" | ||
| 38 | + android:layout_height="wrap_content" | ||
| 39 | + android:background="#44000000" | ||
| 40 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 41 | + | ||
| 42 | + <TextView | ||
| 43 | + android:id="@+id/title" | ||
| 44 | + android:layout_width="wrap_content" | ||
| 45 | + android:layout_height="30dp" | ||
| 46 | + android:layout_marginLeft="50dp" | ||
| 47 | + android:gravity="center" | ||
| 48 | + android:textColor="@android:color/white" | ||
| 49 | + android:text="@{title.get()}" /> | ||
| 50 | + | ||
| 51 | + </RelativeLayout> | ||
| 52 | + | ||
| 53 | + <RelativeLayout | ||
| 54 | + android:id="@+id/bottomLayout" | ||
| 55 | + android:layout_width="match_parent" | ||
| 56 | + android:layout_height="wrap_content" | ||
| 57 | + android:background="#44000000" | ||
| 58 | + android:layout_alignParentBottom="true" | ||
| 59 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 60 | + | ||
| 61 | + <ImageView | ||
| 62 | + android:id="@+id/playBtn" | ||
| 63 | + android:layout_width="30dp" | ||
| 64 | + android:layout_height="30dp" | ||
| 65 | + android:layout_marginRight="5dp" | ||
| 66 | + android:onClick="@{playerControllerView.onClick}" | ||
| 67 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}"/> | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + </RelativeLayout> | ||
| 71 | + | ||
| 72 | + <ImageView | ||
| 73 | + android:id="@+id/back" | ||
| 74 | + android:layout_width="30dp" | ||
| 75 | + android:layout_height="30dp" | ||
| 76 | + android:src="@drawable/player_back" | ||
| 77 | + android:layout_marginLeft="10dp" | ||
| 78 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 79 | + | ||
| 80 | + </RelativeLayout> | ||
| 81 | + | ||
| 82 | +</layout> | ||
| 0 | \ No newline at end of file | 83 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_ugc_vod_l.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + <import type="android.databinding.ObservableField"/> | ||
| 7 | + <import type="android.databinding.ObservableBoolean"/> | ||
| 8 | + <import type="android.databinding.ObservableLong"/> | ||
| 9 | + <import type="com.cnlive.gundam.video.utils.PlayerUtils"/> | ||
| 10 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | ||
| 11 | + <import type="android.view.View"/> | ||
| 12 | + | ||
| 13 | + <variable | ||
| 14 | + name="title" | ||
| 15 | + type="ObservableField<String>"/> | ||
| 16 | + | ||
| 17 | + <variable | ||
| 18 | + name="showController" | ||
| 19 | + type="ObservableBoolean"/> | ||
| 20 | + | ||
| 21 | + <variable | ||
| 22 | + name="isPlay" | ||
| 23 | + type="ObservableBoolean"/> | ||
| 24 | + | ||
| 25 | + <variable | ||
| 26 | + name="curProgress" | ||
| 27 | + type="ObservableLong"/> | ||
| 28 | + | ||
| 29 | + <variable | ||
| 30 | + name="durProgress" | ||
| 31 | + type="ObservableLong"/> | ||
| 32 | + | ||
| 33 | + <variable | ||
| 34 | + name="playerControllerView" | ||
| 35 | + type="PlayerControllerView"/> | ||
| 36 | + | ||
| 37 | + </data> | ||
| 38 | + | ||
| 39 | + <RelativeLayout | ||
| 40 | + android:layout_width="match_parent" | ||
| 41 | + android:layout_height="match_parent"> | ||
| 42 | + | ||
| 43 | + <RelativeLayout | ||
| 44 | + android:id="@+id/topLayout" | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="wrap_content" | ||
| 47 | + android:background="#44000000" | ||
| 48 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 49 | + | ||
| 50 | + <ImageView | ||
| 51 | + android:id="@+id/back" | ||
| 52 | + android:layout_width="30dp" | ||
| 53 | + android:layout_height="30dp" | ||
| 54 | + android:layout_marginLeft="10dp" | ||
| 55 | + android:src="@drawable/player_back" | ||
| 56 | + android:onClick="@{playerControllerView.onClick}" /> | ||
| 57 | + | ||
| 58 | + <TextView | ||
| 59 | + android:id="@+id/title" | ||
| 60 | + android:layout_width="wrap_content" | ||
| 61 | + android:layout_height="30dp" | ||
| 62 | + android:layout_marginLeft="50dp" | ||
| 63 | + android:gravity="center" | ||
| 64 | + android:textColor="@android:color/white" | ||
| 65 | + android:text="@{title.get()}" /> | ||
| 66 | + | ||
| 67 | + </RelativeLayout> | ||
| 68 | + | ||
| 69 | + <RelativeLayout | ||
| 70 | + android:id="@+id/bottomLayout" | ||
| 71 | + android:layout_width="match_parent" | ||
| 72 | + android:layout_height="wrap_content" | ||
| 73 | + android:layout_alignParentBottom="true" | ||
| 74 | + android:background="#44000000" | ||
| 75 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 76 | + | ||
| 77 | + <SeekBar | ||
| 78 | + android:id="@+id/progressBar" | ||
| 79 | + android:layout_width="match_parent" | ||
| 80 | + android:layout_height="wrap_content" | ||
| 81 | + android:progress="@{(int)(curProgress.get() / 1000)}" | ||
| 82 | + android:max="@{(int)(durProgress.get() / 1000)}" | ||
| 83 | + android:onSeekBarChangeListener="@{playerControllerView}"/> | ||
| 84 | + | ||
| 85 | + <RelativeLayout | ||
| 86 | + android:layout_width="match_parent" | ||
| 87 | + android:layout_height="wrap_content" | ||
| 88 | + android:layout_below="@+id/progressBar"> | ||
| 89 | + | ||
| 90 | + <ImageView | ||
| 91 | + android:id="@+id/playBtn" | ||
| 92 | + android:layout_width="30dp" | ||
| 93 | + android:layout_height="30dp" | ||
| 94 | + android:layout_marginRight="5dp" | ||
| 95 | + android:onClick="@{playerControllerView.onClick}" | ||
| 96 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> | ||
| 97 | + | ||
| 98 | + <TextView | ||
| 99 | + android:id="@+id/curTime" | ||
| 100 | + android:layout_width="wrap_content" | ||
| 101 | + android:layout_height="wrap_content" | ||
| 102 | + android:layout_centerVertical="true" | ||
| 103 | + android:layout_toRightOf="@+id/playBtn" | ||
| 104 | + android:textColor="@android:color/white" | ||
| 105 | + android:text="@{PlayerUtils.stringForTime(curProgress.get() / 1000)}" /> | ||
| 106 | + | ||
| 107 | + <TextView | ||
| 108 | + android:id="@+id/lineTime" | ||
| 109 | + android:layout_width="wrap_content" | ||
| 110 | + android:layout_height="wrap_content" | ||
| 111 | + android:layout_centerVertical="true" | ||
| 112 | + android:layout_toRightOf="@+id/curTime" | ||
| 113 | + android:textColor="@android:color/white" | ||
| 114 | + android:text="/" /> | ||
| 115 | + | ||
| 116 | + <TextView | ||
| 117 | + android:id="@+id/durTime" | ||
| 118 | + android:layout_width="wrap_content" | ||
| 119 | + android:layout_height="wrap_content" | ||
| 120 | + android:layout_centerVertical="true" | ||
| 121 | + android:layout_toRightOf="@+id/lineTime" | ||
| 122 | + android:textColor="@android:color/white" | ||
| 123 | + android:text="@{PlayerUtils.stringForTime(durProgress.get() / 1000)}"/> | ||
| 124 | + | ||
| 125 | + </RelativeLayout> | ||
| 126 | + | ||
| 127 | + </RelativeLayout> | ||
| 128 | + | ||
| 129 | + </RelativeLayout> | ||
| 130 | + | ||
| 131 | +</layout> | ||
| 0 | \ No newline at end of file | 132 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_ugc_vod_p.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + <import type="android.databinding.ObservableField"/> | ||
| 7 | + <import type="android.databinding.ObservableBoolean"/> | ||
| 8 | + <import type="android.databinding.ObservableLong"/> | ||
| 9 | + <import type="com.cnlive.gundam.video.utils.PlayerUtils"/> | ||
| 10 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | ||
| 11 | + <import type="android.view.View"/> | ||
| 12 | + | ||
| 13 | + <variable | ||
| 14 | + name="title" | ||
| 15 | + type="ObservableField<String>"/> | ||
| 16 | + | ||
| 17 | + <variable | ||
| 18 | + name="showController" | ||
| 19 | + type="ObservableBoolean"/> | ||
| 20 | + | ||
| 21 | + <variable | ||
| 22 | + name="isPlay" | ||
| 23 | + type="ObservableBoolean"/> | ||
| 24 | + | ||
| 25 | + <variable | ||
| 26 | + name="curProgress" | ||
| 27 | + type="ObservableLong"/> | ||
| 28 | + | ||
| 29 | + <variable | ||
| 30 | + name="durProgress" | ||
| 31 | + type="ObservableLong"/> | ||
| 32 | + | ||
| 33 | + <variable | ||
| 34 | + name="playerControllerView" | ||
| 35 | + type="PlayerControllerView"/> | ||
| 36 | + </data> | ||
| 37 | + | ||
| 38 | + <RelativeLayout | ||
| 39 | + android:layout_width="match_parent" | ||
| 40 | + android:layout_height="match_parent"> | ||
| 41 | + | ||
| 42 | + <RelativeLayout | ||
| 43 | + android:id="@+id/topLayout" | ||
| 44 | + android:layout_width="match_parent" | ||
| 45 | + android:layout_height="wrap_content" | ||
| 46 | + android:background="#44000000" | ||
| 47 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 48 | + | ||
| 49 | + <TextView | ||
| 50 | + android:id="@+id/title" | ||
| 51 | + android:layout_width="wrap_content" | ||
| 52 | + android:layout_height="30dp" | ||
| 53 | + android:layout_marginLeft="50dp" | ||
| 54 | + android:gravity="center" | ||
| 55 | + android:textColor="@android:color/white" | ||
| 56 | + android:text="@{title.get()}" /> | ||
| 57 | + | ||
| 58 | + </RelativeLayout> | ||
| 59 | + | ||
| 60 | + <RelativeLayout | ||
| 61 | + android:id="@+id/bottomLayout" | ||
| 62 | + android:layout_width="match_parent" | ||
| 63 | + android:layout_height="wrap_content" | ||
| 64 | + android:background="#44000000" | ||
| 65 | + android:layout_alignParentBottom="true" | ||
| 66 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 67 | + | ||
| 68 | + <ImageView | ||
| 69 | + android:id="@+id/playBtn" | ||
| 70 | + android:layout_width="30dp" | ||
| 71 | + android:layout_height="30dp" | ||
| 72 | + android:layout_marginRight="5dp" | ||
| 73 | + android:onClick="@{playerControllerView.onClick}" | ||
| 74 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}"/> | ||
| 75 | + | ||
| 76 | + <TextView | ||
| 77 | + android:id="@+id/curTime" | ||
| 78 | + android:layout_width="wrap_content" | ||
| 79 | + android:layout_height="wrap_content" | ||
| 80 | + android:layout_toRightOf="@+id/playBtn" | ||
| 81 | + android:text="@{PlayerUtils.stringForTime(curProgress.get() / 1000)}" | ||
| 82 | + android:textColor="@android:color/white" | ||
| 83 | + android:layout_centerVertical="true"/> | ||
| 84 | + | ||
| 85 | + <SeekBar | ||
| 86 | + android:id="@+id/progressBar" | ||
| 87 | + android:layout_width="match_parent" | ||
| 88 | + android:layout_height="wrap_content" | ||
| 89 | + android:layout_toRightOf="@+id/curTime" | ||
| 90 | + android:layout_toLeftOf="@+id/durTime" | ||
| 91 | + android:progress="@{(int)(curProgress.get() / 1000)}" | ||
| 92 | + android:max="@{(int)(durProgress.get() / 1000)}" | ||
| 93 | + android:layout_centerVertical="true" | ||
| 94 | + android:onSeekBarChangeListener="@{playerControllerView}"/> | ||
| 95 | + | ||
| 96 | + <TextView | ||
| 97 | + android:id="@+id/durTime" | ||
| 98 | + android:layout_width="wrap_content" | ||
| 99 | + android:layout_height="wrap_content" | ||
| 100 | + android:text="@{PlayerUtils.stringForTime(durProgress.get() / 1000)}" | ||
| 101 | + android:layout_marginRight="5dp" | ||
| 102 | + android:layout_toLeftOf="@+id/fullScreen" | ||
| 103 | + android:textColor="@android:color/white" | ||
| 104 | + android:layout_centerVertical="true" | ||
| 105 | + android:layout_alignParentRight="true"/> | ||
| 106 | + | ||
| 107 | + </RelativeLayout> | ||
| 108 | + | ||
| 109 | + <ImageView | ||
| 110 | + android:id="@+id/back" | ||
| 111 | + android:layout_width="30dp" | ||
| 112 | + android:layout_height="30dp" | ||
| 113 | + android:src="@drawable/player_back" | ||
| 114 | + android:layout_marginLeft="10dp" | ||
| 115 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 116 | + | ||
| 117 | + </RelativeLayout> | ||
| 118 | + | ||
| 119 | +</layout> | ||
| 0 | \ No newline at end of file | 120 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_vod_l.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + | ||
| 7 | + <import type="android.databinding.ObservableField" /> | ||
| 8 | + | ||
| 9 | + <import type="android.databinding.ObservableBoolean" /> | ||
| 10 | + | ||
| 11 | + <import type="android.databinding.ObservableLong" /> | ||
| 12 | + | ||
| 13 | + <import type="android.databinding.ObservableInt" /> | ||
| 14 | + | ||
| 15 | + <import type="com.cnlive.gundam.video.utils.PlayerUtils" /> | ||
| 16 | + | ||
| 17 | + <import type="android.view.View" /> | ||
| 18 | + | ||
| 19 | + <import type="com.cnlive.gundam.video.utils.VideoRateUtil" /> | ||
| 20 | + | ||
| 21 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView" /> | ||
| 22 | + | ||
| 23 | + <variable | ||
| 24 | + name="title" | ||
| 25 | + type="ObservableField<String>" /> | ||
| 26 | + | ||
| 27 | + <variable | ||
| 28 | + name="showController" | ||
| 29 | + type="ObservableBoolean" /> | ||
| 30 | + | ||
| 31 | + <variable | ||
| 32 | + name="isPlay" | ||
| 33 | + type="ObservableBoolean" /> | ||
| 34 | + | ||
| 35 | + <variable | ||
| 36 | + name="curProgress" | ||
| 37 | + type="ObservableLong" /> | ||
| 38 | + | ||
| 39 | + <variable | ||
| 40 | + name="durProgress" | ||
| 41 | + type="ObservableLong" /> | ||
| 42 | + | ||
| 43 | + <variable | ||
| 44 | + name="rateType" | ||
| 45 | + type="ObservableInt" /> | ||
| 46 | + | ||
| 47 | + <variable | ||
| 48 | + name="hasRate" | ||
| 49 | + type="ObservableBoolean" /> | ||
| 50 | + | ||
| 51 | + <variable | ||
| 52 | + name="showRateListLayout" | ||
| 53 | + type="ObservableBoolean" /> | ||
| 54 | + | ||
| 55 | + <variable | ||
| 56 | + name="showRateToastLayout" | ||
| 57 | + type="ObservableBoolean" /> | ||
| 58 | + | ||
| 59 | + <variable | ||
| 60 | + name="curSwitchRateType" | ||
| 61 | + type="ObservableInt" /> | ||
| 62 | + | ||
| 63 | + <variable | ||
| 64 | + name="curSwitchRateStr" | ||
| 65 | + type="ObservableField<String>" /> | ||
| 66 | + | ||
| 67 | + <variable | ||
| 68 | + name="rateListStr" | ||
| 69 | + type="ObservableField<String>" /> | ||
| 70 | + | ||
| 71 | + <variable | ||
| 72 | + name="playerControllerView" | ||
| 73 | + type="PlayerControllerView" /> | ||
| 74 | + | ||
| 75 | + </data> | ||
| 76 | + | ||
| 77 | + <RelativeLayout | ||
| 78 | + android:layout_width="match_parent" | ||
| 79 | + android:layout_height="match_parent"> | ||
| 80 | + | ||
| 81 | + <RelativeLayout | ||
| 82 | + android:id="@+id/topLayout" | ||
| 83 | + android:layout_width="match_parent" | ||
| 84 | + android:layout_height="wrap_content" | ||
| 85 | + android:background="#44000000" | ||
| 86 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 87 | + | ||
| 88 | + <ImageView | ||
| 89 | + android:id="@+id/back" | ||
| 90 | + android:layout_width="30dp" | ||
| 91 | + android:layout_height="30dp" | ||
| 92 | + android:layout_marginLeft="10dp" | ||
| 93 | + android:onClick="@{playerControllerView.onClick}" | ||
| 94 | + android:src="@drawable/player_back" /> | ||
| 95 | + | ||
| 96 | + <TextView | ||
| 97 | + android:id="@+id/title" | ||
| 98 | + android:layout_width="wrap_content" | ||
| 99 | + android:layout_height="30dp" | ||
| 100 | + android:layout_marginLeft="50dp" | ||
| 101 | + android:gravity="center" | ||
| 102 | + android:text="@{title.get()}" | ||
| 103 | + android:textColor="@android:color/white" /> | ||
| 104 | + | ||
| 105 | + </RelativeLayout> | ||
| 106 | + | ||
| 107 | + <LinearLayout | ||
| 108 | + android:layout_width="match_parent" | ||
| 109 | + android:layout_height="wrap_content" | ||
| 110 | + android:layout_alignParentBottom="true" | ||
| 111 | + android:orientation="vertical"> | ||
| 112 | + | ||
| 113 | + <RelativeLayout | ||
| 114 | + android:id="@+id/switchVideoRateToastLayout" | ||
| 115 | + android:layout_width="wrap_content" | ||
| 116 | + android:layout_height="wrap_content" | ||
| 117 | + android:layout_above="@+id/bottomLayout" | ||
| 118 | + android:background="@drawable/player_rate_bg" | ||
| 119 | + android:paddingLeft="10dp" | ||
| 120 | + android:paddingRight="10dp" | ||
| 121 | + android:layout_marginBottom="10dp" | ||
| 122 | + android:layout_marginLeft="10dp" | ||
| 123 | + android:visibility="@{showRateToastLayout.get() ? View.VISIBLE : View.GONE}"> | ||
| 124 | + | ||
| 125 | + <TextView | ||
| 126 | + android:id="@+id/toastPre" | ||
| 127 | + android:layout_width="wrap_content" | ||
| 128 | + android:layout_height="wrap_content" | ||
| 129 | + android:layout_centerVertical="true" | ||
| 130 | + android:textColor="@android:color/white" | ||
| 131 | + android:textSize="12sp" | ||
| 132 | + android:text="@{curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_START ? @string/loading_rate_pre : (curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_FINISH ? @string/loaded_rate_pre : @string/loaded_rate_error_pre)}" /> | ||
| 133 | + | ||
| 134 | + <TextView | ||
| 135 | + android:id="@+id/toastText" | ||
| 136 | + android:layout_width="wrap_content" | ||
| 137 | + android:layout_height="wrap_content" | ||
| 138 | + android:layout_centerVertical="true" | ||
| 139 | + android:layout_toRightOf="@+id/toastPre" | ||
| 140 | + android:textColor="@color/rate_sel" | ||
| 141 | + android:textSize="12sp" | ||
| 142 | + android:text="@{curSwitchRateStr.get()}" /> | ||
| 143 | + | ||
| 144 | + <TextView | ||
| 145 | + android:id="@+id/toastLast" | ||
| 146 | + android:layout_width="wrap_content" | ||
| 147 | + android:layout_height="wrap_content" | ||
| 148 | + android:layout_centerVertical="true" | ||
| 149 | + android:layout_toRightOf="@+id/toastText" | ||
| 150 | + android:textColor="@android:color/white" | ||
| 151 | + android:textSize="12sp" | ||
| 152 | + android:text="@{curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_START ? @string/loading_rate_last : (curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_FINISH ? @string/loaded_rate_last : @string/loaded_rate_error_last)}" /> | ||
| 153 | + | ||
| 154 | + </RelativeLayout> | ||
| 155 | + | ||
| 156 | + <RelativeLayout | ||
| 157 | + android:id="@+id/bottomLayout" | ||
| 158 | + android:layout_width="match_parent" | ||
| 159 | + android:layout_height="wrap_content" | ||
| 160 | + android:layout_alignParentBottom="true" | ||
| 161 | + android:background="#44000000" | ||
| 162 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 163 | + | ||
| 164 | + <SeekBar | ||
| 165 | + android:id="@+id/progressBar" | ||
| 166 | + android:layout_width="match_parent" | ||
| 167 | + android:layout_height="wrap_content" | ||
| 168 | + android:max="@{(int)(durProgress.get() / 1000)}" | ||
| 169 | + android:onSeekBarChangeListener="@{playerControllerView}" | ||
| 170 | + android:progress="@{(int)(curProgress.get() / 1000)}" /> | ||
| 171 | + | ||
| 172 | + <RelativeLayout | ||
| 173 | + android:layout_width="match_parent" | ||
| 174 | + android:layout_height="wrap_content" | ||
| 175 | + android:layout_below="@+id/progressBar"> | ||
| 176 | + | ||
| 177 | + <ImageView | ||
| 178 | + android:id="@+id/playBtn" | ||
| 179 | + android:layout_width="30dp" | ||
| 180 | + android:layout_height="30dp" | ||
| 181 | + android:layout_marginRight="5dp" | ||
| 182 | + android:onClick="@{playerControllerView.onClick}" | ||
| 183 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> | ||
| 184 | + | ||
| 185 | + <TextView | ||
| 186 | + android:id="@+id/curTime" | ||
| 187 | + android:layout_width="wrap_content" | ||
| 188 | + android:layout_height="wrap_content" | ||
| 189 | + android:layout_centerVertical="true" | ||
| 190 | + android:layout_toRightOf="@+id/playBtn" | ||
| 191 | + android:text="@{PlayerUtils.stringForTime(curProgress.get() / 1000)}" | ||
| 192 | + android:textColor="@android:color/white" /> | ||
| 193 | + | ||
| 194 | + <TextView | ||
| 195 | + android:id="@+id/lineTime" | ||
| 196 | + android:layout_width="wrap_content" | ||
| 197 | + android:layout_height="wrap_content" | ||
| 198 | + android:layout_centerVertical="true" | ||
| 199 | + android:layout_toRightOf="@+id/curTime" | ||
| 200 | + android:text="/" | ||
| 201 | + android:textColor="@android:color/white" /> | ||
| 202 | + | ||
| 203 | + <TextView | ||
| 204 | + android:id="@+id/durTime" | ||
| 205 | + android:layout_width="wrap_content" | ||
| 206 | + android:layout_height="wrap_content" | ||
| 207 | + android:layout_centerVertical="true" | ||
| 208 | + android:layout_toRightOf="@+id/lineTime" | ||
| 209 | + android:text="@{PlayerUtils.stringForTime(durProgress.get() / 1000)}" | ||
| 210 | + android:textColor="@android:color/white" /> | ||
| 211 | + | ||
| 212 | + <TextView | ||
| 213 | + android:id="@+id/rate" | ||
| 214 | + android:layout_width="wrap_content" | ||
| 215 | + android:layout_height="wrap_content" | ||
| 216 | + android:layout_alignParentRight="true" | ||
| 217 | + android:layout_centerVertical="true" | ||
| 218 | + android:layout_marginRight="10dp" | ||
| 219 | + android:onClick="@{playerControllerView.onClick}" | ||
| 220 | + android:text="@{VideoRateUtil.getRateText(rateType.get())}" | ||
| 221 | + android:textColor="@android:color/white" | ||
| 222 | + android:visibility="@{hasRate.get() ? View.VISIBLE : View.GONE}" /> | ||
| 223 | + | ||
| 224 | + </RelativeLayout> | ||
| 225 | + | ||
| 226 | + </RelativeLayout> | ||
| 227 | + | ||
| 228 | + </LinearLayout> | ||
| 229 | + | ||
| 230 | + <RelativeLayout | ||
| 231 | + android:id="@+id/rateLayout" | ||
| 232 | + android:layout_width="match_parent" | ||
| 233 | + android:layout_height="match_parent" | ||
| 234 | + android:visibility="@{showRateListLayout.get() ? View.VISIBLE : View.GONE}"> | ||
| 235 | + | ||
| 236 | + <View | ||
| 237 | + android:id="@+id/rateOutClickView" | ||
| 238 | + android:layout_width="match_parent" | ||
| 239 | + android:layout_height="match_parent" | ||
| 240 | + android:layout_toLeftOf="@+id/rightLayout" | ||
| 241 | + android:onClick="@{playerControllerView.onClick}" /> | ||
| 242 | + | ||
| 243 | + <LinearLayout | ||
| 244 | + android:id="@+id/rightLayout" | ||
| 245 | + android:layout_width="124dp" | ||
| 246 | + android:layout_height="match_parent" | ||
| 247 | + android:layout_alignParentRight="true" | ||
| 248 | + android:background="#4c000000" | ||
| 249 | + android:gravity="center_horizontal" | ||
| 250 | + android:orientation="vertical"> | ||
| 251 | + | ||
| 252 | + <LinearLayout | ||
| 253 | + android:layout_width="wrap_content" | ||
| 254 | + android:layout_height="wrap_content" | ||
| 255 | + android:layout_weight="1" | ||
| 256 | + android:gravity="center" | ||
| 257 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_L) ? View.VISIBLE : View.GONE}"> | ||
| 258 | + | ||
| 259 | + <TextView | ||
| 260 | + android:id="@+id/rateL" | ||
| 261 | + android:layout_width="wrap_content" | ||
| 262 | + android:layout_height="wrap_content" | ||
| 263 | + android:button="@null" | ||
| 264 | + android:gravity="center" | ||
| 265 | + android:onClick="@{playerControllerView.onClick}" | ||
| 266 | + android:paddingBottom="5dp" | ||
| 267 | + android:paddingLeft="10dp" | ||
| 268 | + android:paddingRight="10dp" | ||
| 269 | + android:paddingTop="5dp" | ||
| 270 | + android:text="流畅" | ||
| 271 | + android:textColor="@{rateType == PlayerControllerView.RATE_L ? @color/rate_sel : @color/rate_nor}" | ||
| 272 | + android:textSize="17sp" /> | ||
| 273 | + </LinearLayout> | ||
| 274 | + | ||
| 275 | + | ||
| 276 | + <LinearLayout | ||
| 277 | + android:layout_width="wrap_content" | ||
| 278 | + android:layout_height="wrap_content" | ||
| 279 | + android:layout_weight="1" | ||
| 280 | + android:gravity="center" | ||
| 281 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_M) ? View.VISIBLE : View.GONE}"> | ||
| 282 | + | ||
| 283 | + <TextView | ||
| 284 | + android:id="@+id/rateM" | ||
| 285 | + android:layout_width="wrap_content" | ||
| 286 | + android:layout_height="wrap_content" | ||
| 287 | + android:button="@null" | ||
| 288 | + android:gravity="center" | ||
| 289 | + android:onClick="@{playerControllerView.onClick}" | ||
| 290 | + android:paddingBottom="5dp" | ||
| 291 | + android:paddingLeft="10dp" | ||
| 292 | + android:paddingRight="10dp" | ||
| 293 | + android:paddingTop="5dp" | ||
| 294 | + android:text="标清" | ||
| 295 | + android:textColor="@{rateType == PlayerControllerView.RATE_M ? @color/rate_sel : @color/rate_nor}" | ||
| 296 | + android:textSize="17sp" /> | ||
| 297 | + </LinearLayout> | ||
| 298 | + | ||
| 299 | + <LinearLayout | ||
| 300 | + android:layout_width="wrap_content" | ||
| 301 | + android:layout_height="wrap_content" | ||
| 302 | + android:layout_weight="1" | ||
| 303 | + android:gravity="center" | ||
| 304 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_H) ? View.VISIBLE : View.GONE}"> | ||
| 305 | + | ||
| 306 | + <TextView | ||
| 307 | + android:id="@+id/rateH" | ||
| 308 | + android:layout_width="wrap_content" | ||
| 309 | + android:layout_height="wrap_content" | ||
| 310 | + android:button="@null" | ||
| 311 | + android:gravity="center" | ||
| 312 | + android:onClick="@{playerControllerView.onClick}" | ||
| 313 | + android:paddingBottom="5dp" | ||
| 314 | + android:paddingLeft="10dp" | ||
| 315 | + android:paddingRight="10dp" | ||
| 316 | + android:paddingTop="5dp" | ||
| 317 | + android:text="高清" | ||
| 318 | + android:textColor="@{rateType == PlayerControllerView.RATE_H ? @color/rate_sel : @color/rate_nor}" | ||
| 319 | + android:textSize="17sp" /> | ||
| 320 | + </LinearLayout> | ||
| 321 | + | ||
| 322 | + <LinearLayout | ||
| 323 | + android:layout_width="wrap_content" | ||
| 324 | + android:layout_height="wrap_content" | ||
| 325 | + android:layout_weight="1" | ||
| 326 | + android:gravity="center" | ||
| 327 | + android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_HH) ? View.VISIBLE : View.GONE}"> | ||
| 328 | + | ||
| 329 | + <TextView | ||
| 330 | + android:id="@+id/rateHH" | ||
| 331 | + android:layout_width="wrap_content" | ||
| 332 | + android:layout_height="wrap_content" | ||
| 333 | + android:button="@null" | ||
| 334 | + android:gravity="center" | ||
| 335 | + android:onClick="@{playerControllerView.onClick}" | ||
| 336 | + android:paddingBottom="5dp" | ||
| 337 | + android:paddingLeft="10dp" | ||
| 338 | + android:paddingRight="10dp" | ||
| 339 | + android:paddingTop="5dp" | ||
| 340 | + android:text="超高清" | ||
| 341 | + android:textColor="@{rateType == PlayerControllerView.RATE_HH ? @color/rate_sel : @color/rate_nor}" | ||
| 342 | + android:textSize="17sp" /> | ||
| 343 | + </LinearLayout> | ||
| 344 | + | ||
| 345 | + </LinearLayout> | ||
| 346 | + | ||
| 347 | + </RelativeLayout> | ||
| 348 | + | ||
| 349 | + </RelativeLayout> | ||
| 350 | + | ||
| 351 | +</layout> | ||
| 0 | \ No newline at end of file | 352 | \ No newline at end of file |
app/src/main/res/layout/layout_player_controller_vod_p.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + <import type="android.databinding.ObservableField"/> | ||
| 7 | + <import type="android.databinding.ObservableBoolean"/> | ||
| 8 | + <import type="android.databinding.ObservableLong"/> | ||
| 9 | + <import type="com.cnlive.gundam.video.utils.PlayerUtils"/> | ||
| 10 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | ||
| 11 | + <import type="android.view.View"/> | ||
| 12 | + | ||
| 13 | + <variable | ||
| 14 | + name="title" | ||
| 15 | + type="ObservableField<String>"/> | ||
| 16 | + | ||
| 17 | + <variable | ||
| 18 | + name="showController" | ||
| 19 | + type="ObservableBoolean"/> | ||
| 20 | + | ||
| 21 | + <variable | ||
| 22 | + name="isPlay" | ||
| 23 | + type="ObservableBoolean"/> | ||
| 24 | + | ||
| 25 | + <variable | ||
| 26 | + name="curProgress" | ||
| 27 | + type="ObservableLong"/> | ||
| 28 | + | ||
| 29 | + <variable | ||
| 30 | + name="durProgress" | ||
| 31 | + type="ObservableLong"/> | ||
| 32 | + | ||
| 33 | + <variable | ||
| 34 | + name="playerControllerView" | ||
| 35 | + type="PlayerControllerView"/> | ||
| 36 | + | ||
| 37 | + </data> | ||
| 38 | + | ||
| 39 | + <RelativeLayout | ||
| 40 | + android:layout_width="match_parent" | ||
| 41 | + android:layout_height="match_parent"> | ||
| 42 | + | ||
| 43 | + <RelativeLayout | ||
| 44 | + android:id="@+id/topLayout" | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="wrap_content" | ||
| 47 | + android:background="#44000000" | ||
| 48 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 49 | + | ||
| 50 | + <TextView | ||
| 51 | + android:id="@+id/title" | ||
| 52 | + android:layout_width="wrap_content" | ||
| 53 | + android:layout_height="30dp" | ||
| 54 | + android:layout_marginLeft="50dp" | ||
| 55 | + android:gravity="center" | ||
| 56 | + android:textColor="@android:color/white" | ||
| 57 | + android:text="@{title.get()}" /> | ||
| 58 | + | ||
| 59 | + </RelativeLayout> | ||
| 60 | + | ||
| 61 | + <RelativeLayout | ||
| 62 | + android:id="@+id/bottomLayout" | ||
| 63 | + android:layout_width="match_parent" | ||
| 64 | + android:layout_height="wrap_content" | ||
| 65 | + android:background="#44000000" | ||
| 66 | + android:layout_alignParentBottom="true" | ||
| 67 | + android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> | ||
| 68 | + | ||
| 69 | + <ImageView | ||
| 70 | + android:id="@+id/playBtn" | ||
| 71 | + android:layout_width="30dp" | ||
| 72 | + android:layout_height="30dp" | ||
| 73 | + android:layout_marginRight="5dp" | ||
| 74 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" | ||
| 75 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 76 | + | ||
| 77 | + <TextView | ||
| 78 | + android:id="@+id/curTime" | ||
| 79 | + android:layout_width="wrap_content" | ||
| 80 | + android:layout_height="wrap_content" | ||
| 81 | + android:layout_toRightOf="@+id/playBtn" | ||
| 82 | + android:text="@{PlayerUtils.stringForTime(curProgress.get() / 1000)}" | ||
| 83 | + android:textColor="@android:color/white" | ||
| 84 | + android:layout_centerVertical="true"/> | ||
| 85 | + | ||
| 86 | + <SeekBar | ||
| 87 | + android:id="@+id/progressBar" | ||
| 88 | + android:layout_width="match_parent" | ||
| 89 | + android:layout_height="wrap_content" | ||
| 90 | + android:layout_toRightOf="@+id/curTime" | ||
| 91 | + android:layout_toLeftOf="@+id/durTime" | ||
| 92 | + android:progress="@{(int)(curProgress.get() / 1000)}" | ||
| 93 | + android:max="@{(int)(durProgress.get() / 1000)}" | ||
| 94 | + android:layout_centerVertical="true" | ||
| 95 | + android:onSeekBarChangeListener="@{playerControllerView}"/> | ||
| 96 | + | ||
| 97 | + <TextView | ||
| 98 | + android:id="@+id/durTime" | ||
| 99 | + android:layout_width="wrap_content" | ||
| 100 | + android:layout_height="wrap_content" | ||
| 101 | + android:text="@{PlayerUtils.stringForTime(durProgress.get() / 1000)}" | ||
| 102 | + android:layout_marginRight="5dp" | ||
| 103 | + android:layout_toLeftOf="@+id/fullScreen" | ||
| 104 | + android:textColor="@android:color/white" | ||
| 105 | + android:layout_centerVertical="true"/> | ||
| 106 | + | ||
| 107 | + <ImageView | ||
| 108 | + android:id="@+id/fullScreen" | ||
| 109 | + android:layout_width="30dp" | ||
| 110 | + android:layout_height="30dp" | ||
| 111 | + android:src="@drawable/player_full_screen" | ||
| 112 | + android:layout_alignParentRight="true" | ||
| 113 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 114 | + | ||
| 115 | + </RelativeLayout> | ||
| 116 | + | ||
| 117 | + <ImageView | ||
| 118 | + android:id="@+id/back" | ||
| 119 | + android:layout_width="30dp" | ||
| 120 | + android:layout_height="30dp" | ||
| 121 | + android:src="@drawable/player_back" | ||
| 122 | + android:layout_marginLeft="10dp" | ||
| 123 | + android:onClick="@{playerControllerView.onClick}"/> | ||
| 124 | + | ||
| 125 | + </RelativeLayout> | ||
| 126 | + | ||
| 127 | +</layout> | ||
| 0 | \ No newline at end of file | 128 | \ No newline at end of file |
app/src/main/res/layout/layout_player_info.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + | ||
| 7 | + <import type="android.databinding.ObservableInt" /> | ||
| 8 | + | ||
| 9 | + <import type="android.databinding.ObservableBoolean" /> | ||
| 10 | + | ||
| 11 | + <import type="com.cnlive.gundam.video.view.PlayerInfoView" /> | ||
| 12 | + | ||
| 13 | + <import type="android.view.View" /> | ||
| 14 | + | ||
| 15 | + <import type="android.databinding.ObservableField" /> | ||
| 16 | + | ||
| 17 | + <variable | ||
| 18 | + name="showType" | ||
| 19 | + type="ObservableInt" /> | ||
| 20 | + | ||
| 21 | + <variable | ||
| 22 | + name="isNews" | ||
| 23 | + type="ObservableBoolean" /> | ||
| 24 | + | ||
| 25 | + <variable | ||
| 26 | + name="isPortrait" | ||
| 27 | + type="ObservableBoolean" /> | ||
| 28 | + | ||
| 29 | + <variable | ||
| 30 | + name="playerInfoView" | ||
| 31 | + type="PlayerInfoView"/> | ||
| 32 | + | ||
| 33 | + <variable | ||
| 34 | + name="errorMsg" | ||
| 35 | + type="ObservableField<String>" /> | ||
| 36 | + | ||
| 37 | + </data> | ||
| 38 | + | ||
| 39 | + <RelativeLayout | ||
| 40 | + android:layout_width="match_parent" | ||
| 41 | + android:layout_height="match_parent"> | ||
| 42 | + | ||
| 43 | + <RelativeLayout | ||
| 44 | + android:id="@+id/loadingLayout" | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="match_parent" | ||
| 47 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_LOADING ? View.VISIBLE : View.GONE}" | ||
| 48 | + tools:visibility="gone"> | ||
| 49 | + | ||
| 50 | + <LinearLayout | ||
| 51 | + android:layout_width="wrap_content" | ||
| 52 | + android:layout_height="wrap_content" | ||
| 53 | + android:layout_centerInParent="true" | ||
| 54 | + android:gravity="center" | ||
| 55 | + android:orientation="vertical"> | ||
| 56 | + | ||
| 57 | + <ProgressBar | ||
| 58 | + android:id="@+id/loading" | ||
| 59 | + android:layout_width="50dp" | ||
| 60 | + android:layout_height="50dp" /> | ||
| 61 | + | ||
| 62 | + <TextView | ||
| 63 | + android:layout_width="wrap_content" | ||
| 64 | + android:layout_height="wrap_content" | ||
| 65 | + android:layout_below="@+id/loading" | ||
| 66 | + android:textColor="@android:color/white" | ||
| 67 | + tools:text="@string/player_loading" /> | ||
| 68 | + | ||
| 69 | + </LinearLayout> | ||
| 70 | + | ||
| 71 | + </RelativeLayout> | ||
| 72 | + | ||
| 73 | + <RelativeLayout | ||
| 74 | + android:id="@+id/bufferingLayout" | ||
| 75 | + android:layout_width="match_parent" | ||
| 76 | + android:layout_height="match_parent" | ||
| 77 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_BUFFERING ? View.VISIBLE : View.GONE}" | ||
| 78 | + tools:visibility="visible"> | ||
| 79 | + | ||
| 80 | + <LinearLayout | ||
| 81 | + android:layout_width="wrap_content" | ||
| 82 | + android:layout_height="wrap_content" | ||
| 83 | + android:layout_centerInParent="true" | ||
| 84 | + android:gravity="center" | ||
| 85 | + android:orientation="vertical"> | ||
| 86 | + | ||
| 87 | + <ProgressBar | ||
| 88 | + android:layout_width="50dp" | ||
| 89 | + android:layout_height="50dp" /> | ||
| 90 | + | ||
| 91 | + </LinearLayout> | ||
| 92 | + | ||
| 93 | + </RelativeLayout> | ||
| 94 | + | ||
| 95 | + <LinearLayout | ||
| 96 | + android:id="@+id/errorLayout" | ||
| 97 | + android:layout_width="match_parent" | ||
| 98 | + android:layout_height="match_parent" | ||
| 99 | + android:background="#000000" | ||
| 100 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_ERROR ? View.VISIBLE : View.GONE}" | ||
| 101 | + tools:visibility="gone" | ||
| 102 | + android:gravity="center" | ||
| 103 | + android:orientation="vertical"> | ||
| 104 | + | ||
| 105 | + <TextView | ||
| 106 | + android:layout_width="wrap_content" | ||
| 107 | + android:layout_height="wrap_content" | ||
| 108 | + android:text="@{errorMsg.get()}" | ||
| 109 | + android:textColor="@android:color/white" | ||
| 110 | + android:layout_marginBottom="20dp"/> | ||
| 111 | + | ||
| 112 | + <TextView | ||
| 113 | + android:id="@+id/retry" | ||
| 114 | + android:layout_width="wrap_content" | ||
| 115 | + android:layout_height="wrap_content" | ||
| 116 | + android:background="@drawable/player_btn_bg" | ||
| 117 | + android:gravity="center" | ||
| 118 | + android:text="@string/player_retry" | ||
| 119 | + android:onClick="@{playerInfoView.onClick}" | ||
| 120 | + android:textColor="@android:color/white" /> | ||
| 121 | + | ||
| 122 | + </LinearLayout> | ||
| 123 | + | ||
| 124 | + <LinearLayout | ||
| 125 | + android:id="@+id/mobileNetLayout" | ||
| 126 | + android:layout_width="match_parent" | ||
| 127 | + android:layout_height="match_parent" | ||
| 128 | + android:background="#000000" | ||
| 129 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_MOBILE_NET ? View.VISIBLE : View.GONE}" | ||
| 130 | + tools:visibility="gone" | ||
| 131 | + android:gravity="center" | ||
| 132 | + android:orientation="vertical"> | ||
| 133 | + | ||
| 134 | + <TextView | ||
| 135 | + android:layout_width="wrap_content" | ||
| 136 | + android:layout_height="wrap_content" | ||
| 137 | + android:text="@string/player_mobile_net" | ||
| 138 | + android:textColor="@android:color/white" | ||
| 139 | + android:layout_marginBottom="20dp"/> | ||
| 140 | + | ||
| 141 | + <TextView | ||
| 142 | + android:id="@+id/playByMobileNet" | ||
| 143 | + android:layout_width="wrap_content" | ||
| 144 | + android:layout_height="wrap_content" | ||
| 145 | + android:background="@drawable/player_btn_bg" | ||
| 146 | + android:gravity="center" | ||
| 147 | + android:text="@string/player_continue_play" | ||
| 148 | + android:onClick="@{playerInfoView.onClick}" | ||
| 149 | + android:textColor="@android:color/white" /> | ||
| 150 | + | ||
| 151 | + </LinearLayout> | ||
| 152 | + | ||
| 153 | + <RelativeLayout | ||
| 154 | + android:id="@+id/endLayout" | ||
| 155 | + android:layout_width="match_parent" | ||
| 156 | + android:layout_height="match_parent" | ||
| 157 | + android:background="#000000" | ||
| 158 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_END ? View.VISIBLE : View.GONE}" | ||
| 159 | + tools:visibility="gone"> | ||
| 160 | + | ||
| 161 | + <TextView | ||
| 162 | + android:id="@+id/replay" | ||
| 163 | + android:layout_width="wrap_content" | ||
| 164 | + android:layout_height="wrap_content" | ||
| 165 | + android:layout_centerInParent="true" | ||
| 166 | + android:background="@drawable/player_btn_bg" | ||
| 167 | + android:gravity="center" | ||
| 168 | + android:text="@string/player_replay" | ||
| 169 | + android:onClick="@{playerInfoView.onClick}" | ||
| 170 | + android:textColor="@android:color/white" /> | ||
| 171 | + | ||
| 172 | + </RelativeLayout> | ||
| 173 | + | ||
| 174 | + <ImageView | ||
| 175 | + android:id="@+id/back" | ||
| 176 | + android:layout_width="30dp" | ||
| 177 | + android:layout_height="30dp" | ||
| 178 | + android:layout_marginLeft="10dp" | ||
| 179 | + android:src="@drawable/player_back" | ||
| 180 | + android:onClick="@{playerInfoView.onClick}" | ||
| 181 | + android:visibility="@{(showType.get() == PlayerInfoView.SHOW_BUFFERING || showType.get() == PlayerInfoView.SHOW_NULL) ? View.GONE : (isNews.get() ? (isPortrait.get() ? View.GONE : View.VISIBLE) : View.VISIBLE)}" /> | ||
| 182 | + | ||
| 183 | + </RelativeLayout> | ||
| 184 | + | ||
| 185 | +</layout> | ||
| 0 | \ No newline at end of file | 186 | \ No newline at end of file |
app/src/main/res/layout/layout_player_touch.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + <import type="android.view.View"/> | ||
| 7 | + | ||
| 8 | + <variable | ||
| 9 | + name="leftAreaMove" | ||
| 10 | + type="android.databinding.ObservableBoolean"/> | ||
| 11 | + | ||
| 12 | + <variable | ||
| 13 | + name="rightAreaMove" | ||
| 14 | + type="android.databinding.ObservableBoolean"/> | ||
| 15 | + | ||
| 16 | + <variable | ||
| 17 | + name="brightnessAndVolumeProgress" | ||
| 18 | + type="android.databinding.ObservableInt"/> | ||
| 19 | + </data> | ||
| 20 | + | ||
| 21 | + <RelativeLayout | ||
| 22 | + android:layout_width="match_parent" | ||
| 23 | + android:layout_height="match_parent"> | ||
| 24 | + | ||
| 25 | + <LinearLayout | ||
| 26 | + android:id="@+id/operationVolumeBrightness" | ||
| 27 | + android:layout_width="wrap_content" | ||
| 28 | + android:layout_height="wrap_content" | ||
| 29 | + android:layout_centerInParent="true" | ||
| 30 | + android:background="@drawable/player_volumn_bg" | ||
| 31 | + android:orientation="vertical" | ||
| 32 | + android:padding="0dip" | ||
| 33 | + android:visibility="@{(leftAreaMove.get() || rightAreaMove.get()) ? View.VISIBLE : View.GONE}"> | ||
| 34 | + | ||
| 35 | + <ImageView | ||
| 36 | + android:id="@+id/operationImage" | ||
| 37 | + android:layout_width="45dp" | ||
| 38 | + android:layout_height="45dp" | ||
| 39 | + android:layout_gravity="center_horizontal" | ||
| 40 | + android:layout_marginTop="12dp" | ||
| 41 | + android:contentDescription="@null" | ||
| 42 | + android:src="@{leftAreaMove.get() ? @drawable/player_volume : @drawable/player_brightness}"/> | ||
| 43 | + | ||
| 44 | + <FrameLayout | ||
| 45 | + android:layout_width="wrap_content" | ||
| 46 | + android:layout_height="wrap_content" | ||
| 47 | + android:layout_gravity="center_horizontal" | ||
| 48 | + android:layout_marginTop="10dp"> | ||
| 49 | + | ||
| 50 | + <ImageView | ||
| 51 | + android:id="@+id/operationFull" | ||
| 52 | + android:layout_width="93dp" | ||
| 53 | + android:layout_height="2dp" | ||
| 54 | + android:layout_gravity="left" | ||
| 55 | + android:contentDescription="@null" | ||
| 56 | + android:src="#33ffffff" /> | ||
| 57 | + | ||
| 58 | + <ImageView | ||
| 59 | + android:id="@+id/operationPercent" | ||
| 60 | + android:layout_width="@{brightnessAndVolumeProgress.get(),default=@dimen/volumeWidthDefault}" | ||
| 61 | + android:layout_height="2dp" | ||
| 62 | + android:layout_gravity="left" | ||
| 63 | + android:contentDescription="@null" | ||
| 64 | + android:scaleType="matrix" | ||
| 65 | + android:src="#ff6633"/> | ||
| 66 | + </FrameLayout> | ||
| 67 | + </LinearLayout> | ||
| 68 | + | ||
| 69 | + </RelativeLayout> | ||
| 70 | + | ||
| 71 | + | ||
| 72 | +</layout> | ||
| 0 | \ No newline at end of file | 73 | \ No newline at end of file |
app/src/main/res/layout/layout_player_ugc_info.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools"> | ||
| 4 | + | ||
| 5 | + <data> | ||
| 6 | + <import type="android.databinding.ObservableInt"/> | ||
| 7 | + <import type="android.databinding.ObservableField"/> | ||
| 8 | + <import type="com.cnlive.gundam.video.view.PlayerInfoView"/> | ||
| 9 | + <import type="android.view.View"/> | ||
| 10 | + | ||
| 11 | + <variable | ||
| 12 | + name="showType" | ||
| 13 | + type="ObservableInt"/> | ||
| 14 | + | ||
| 15 | + <variable | ||
| 16 | + name="statusMsg" | ||
| 17 | + type="ObservableField<String>"/> | ||
| 18 | + | ||
| 19 | + <variable | ||
| 20 | + name="playerInfoView" | ||
| 21 | + type="PlayerInfoView"/> | ||
| 22 | + | ||
| 23 | + <variable | ||
| 24 | + name="errorMsg" | ||
| 25 | + type="ObservableField<String>" /> | ||
| 26 | + | ||
| 27 | + </data> | ||
| 28 | + | ||
| 29 | + <RelativeLayout | ||
| 30 | + android:layout_width="match_parent" | ||
| 31 | + android:layout_height="match_parent"> | ||
| 32 | + | ||
| 33 | + <RelativeLayout | ||
| 34 | + android:id="@+id/loadingLayout" | ||
| 35 | + android:layout_width="match_parent" | ||
| 36 | + android:layout_height="match_parent" | ||
| 37 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_LOADING ? View.VISIBLE : View.GONE}" | ||
| 38 | + tools:visibility="gone" | ||
| 39 | + android:background="#000000"> | ||
| 40 | + | ||
| 41 | + <LinearLayout | ||
| 42 | + android:layout_width="wrap_content" | ||
| 43 | + android:layout_height="wrap_content" | ||
| 44 | + android:layout_centerInParent="true" | ||
| 45 | + android:gravity="center" | ||
| 46 | + android:orientation="vertical"> | ||
| 47 | + | ||
| 48 | + <ProgressBar | ||
| 49 | + android:id="@+id/loading" | ||
| 50 | + android:layout_width="50dp" | ||
| 51 | + android:layout_height="50dp" /> | ||
| 52 | + | ||
| 53 | + <TextView | ||
| 54 | + android:layout_width="wrap_content" | ||
| 55 | + android:layout_height="wrap_content" | ||
| 56 | + android:layout_below="@+id/loading" | ||
| 57 | + android:textColor="@android:color/white" | ||
| 58 | + tools:text="@string/player_loading" /> | ||
| 59 | + | ||
| 60 | + </LinearLayout> | ||
| 61 | + | ||
| 62 | + </RelativeLayout> | ||
| 63 | + | ||
| 64 | + <RelativeLayout | ||
| 65 | + android:id="@+id/bufferingLayout" | ||
| 66 | + android:layout_width="match_parent" | ||
| 67 | + android:layout_height="match_parent" | ||
| 68 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_BUFFERING ? View.VISIBLE : View.GONE}" | ||
| 69 | + tools:visibility="visible"> | ||
| 70 | + | ||
| 71 | + <LinearLayout | ||
| 72 | + android:layout_width="wrap_content" | ||
| 73 | + android:layout_height="wrap_content" | ||
| 74 | + android:layout_centerInParent="true" | ||
| 75 | + android:gravity="center" | ||
| 76 | + android:orientation="vertical"> | ||
| 77 | + | ||
| 78 | + <ProgressBar | ||
| 79 | + android:layout_width="50dp" | ||
| 80 | + android:layout_height="50dp" /> | ||
| 81 | + | ||
| 82 | + </LinearLayout> | ||
| 83 | + | ||
| 84 | + </RelativeLayout> | ||
| 85 | + | ||
| 86 | + <LinearLayout | ||
| 87 | + android:id="@+id/errorLayout" | ||
| 88 | + android:layout_width="match_parent" | ||
| 89 | + android:layout_height="match_parent" | ||
| 90 | + android:background="#000000" | ||
| 91 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_ERROR ? View.VISIBLE : View.GONE}" | ||
| 92 | + tools:visibility="gone" | ||
| 93 | + android:gravity="center" | ||
| 94 | + android:orientation="vertical"> | ||
| 95 | + | ||
| 96 | + <TextView | ||
| 97 | + android:layout_width="wrap_content" | ||
| 98 | + android:layout_height="wrap_content" | ||
| 99 | + android:text="@{errorMsg.get()}" | ||
| 100 | + android:textColor="@android:color/white" | ||
| 101 | + android:layout_marginBottom="20dp"/> | ||
| 102 | + | ||
| 103 | + <TextView | ||
| 104 | + android:id="@+id/retry" | ||
| 105 | + android:layout_width="wrap_content" | ||
| 106 | + android:layout_height="wrap_content" | ||
| 107 | + android:background="@drawable/player_btn_bg" | ||
| 108 | + android:gravity="center" | ||
| 109 | + android:text="@string/player_retry" | ||
| 110 | + android:onClick="@{playerInfoView.onClick}" | ||
| 111 | + android:textColor="@android:color/white" /> | ||
| 112 | + | ||
| 113 | + </LinearLayout> | ||
| 114 | + | ||
| 115 | + <LinearLayout | ||
| 116 | + android:id="@+id/mobileNetLayout" | ||
| 117 | + android:layout_width="match_parent" | ||
| 118 | + android:layout_height="match_parent" | ||
| 119 | + android:background="#000000" | ||
| 120 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_MOBILE_NET ? View.VISIBLE : View.GONE}" | ||
| 121 | + tools:visibility="gone" | ||
| 122 | + android:gravity="center" | ||
| 123 | + android:orientation="vertical"> | ||
| 124 | + | ||
| 125 | + <TextView | ||
| 126 | + android:layout_width="wrap_content" | ||
| 127 | + android:layout_height="wrap_content" | ||
| 128 | + android:text="@string/player_mobile_net" | ||
| 129 | + android:textColor="@android:color/white" | ||
| 130 | + android:layout_marginBottom="20dp"/> | ||
| 131 | + | ||
| 132 | + <TextView | ||
| 133 | + android:id="@+id/playByMobileNet" | ||
| 134 | + android:layout_width="wrap_content" | ||
| 135 | + android:layout_height="wrap_content" | ||
| 136 | + android:background="@drawable/player_btn_bg" | ||
| 137 | + android:gravity="center" | ||
| 138 | + android:text="@string/player_continue_play" | ||
| 139 | + android:onClick="@{playerInfoView.onClick}" | ||
| 140 | + android:textColor="@android:color/white" /> | ||
| 141 | + | ||
| 142 | + </LinearLayout> | ||
| 143 | + | ||
| 144 | + <RelativeLayout | ||
| 145 | + android:id="@+id/endLayout" | ||
| 146 | + android:layout_width="match_parent" | ||
| 147 | + android:layout_height="match_parent" | ||
| 148 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_END ? View.VISIBLE : View.GONE}" | ||
| 149 | + tools:visibility="gone" | ||
| 150 | + android:background="#000000"> | ||
| 151 | + | ||
| 152 | + <TextView | ||
| 153 | + android:id="@+id/replay" | ||
| 154 | + android:layout_width="wrap_content" | ||
| 155 | + android:layout_height="wrap_content" | ||
| 156 | + android:text="@string/player_replay" | ||
| 157 | + android:gravity="center" | ||
| 158 | + android:background="@drawable/player_btn_bg" | ||
| 159 | + android:textColor="@android:color/white" | ||
| 160 | + android:layout_centerInParent="true" | ||
| 161 | + android:onClick="@{playerInfoView.onClick}"/> | ||
| 162 | + | ||
| 163 | + </RelativeLayout> | ||
| 164 | + | ||
| 165 | + <RelativeLayout | ||
| 166 | + android:id="@+id/ugcLiveStatusLayout" | ||
| 167 | + android:layout_width="match_parent" | ||
| 168 | + android:layout_height="match_parent" | ||
| 169 | + android:visibility="@{showType.get() == PlayerInfoView.SHOW_UGC_LIVE_STATUS ? View.VISIBLE : View.GONE}" | ||
| 170 | + tools:visibility="gone" | ||
| 171 | + android:background="#000000"> | ||
| 172 | + | ||
| 173 | + <TextView | ||
| 174 | + android:layout_width="wrap_content" | ||
| 175 | + android:layout_height="wrap_content" | ||
| 176 | + android:text="@{statusMsg.get()}" | ||
| 177 | + android:gravity="center" | ||
| 178 | + android:textColor="@android:color/white" | ||
| 179 | + android:layout_centerInParent="true"/> | ||
| 180 | + | ||
| 181 | + </RelativeLayout> | ||
| 182 | + | ||
| 183 | + <ImageView | ||
| 184 | + android:id="@+id/back" | ||
| 185 | + android:layout_width="30dp" | ||
| 186 | + android:layout_height="30dp" | ||
| 187 | + android:src="@drawable/player_back" | ||
| 188 | + android:layout_marginLeft="10dp" | ||
| 189 | + android:onClick="@{playerInfoView.onClick}" | ||
| 190 | + android:visibility="@{(showType.get() == PlayerInfoView.SHOW_BUFFERING || showType.get() == PlayerInfoView.SHOW_NULL) ? View.GONE : View.VISIBLE}"/> | ||
| 191 | + | ||
| 192 | + </RelativeLayout> | ||
| 193 | + | ||
| 194 | +</layout> | ||
| 0 | \ No newline at end of file | 195 | \ No newline at end of file |
app/src/main/res/layout/layout_video_view.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <data> | ||
| 5 | + | ||
| 6 | + <import type="android.databinding.ObservableBoolean"/> | ||
| 7 | + <import type="android.databinding.ObservableInt"/> | ||
| 8 | + <import type="android.view.ViewGroup.LayoutParams"/> | ||
| 9 | + | ||
| 10 | + <variable | ||
| 11 | + name="isPortrait" | ||
| 12 | + type="ObservableBoolean"/> | ||
| 13 | + | ||
| 14 | + <variable | ||
| 15 | + name="isUgc" | ||
| 16 | + type="ObservableBoolean"/> | ||
| 17 | + | ||
| 18 | + <variable | ||
| 19 | + name="videoPortraitHeight" | ||
| 20 | + type="ObservableInt"/> | ||
| 21 | + | ||
| 22 | + <variable | ||
| 23 | + name="videoPortraitWidth" | ||
| 24 | + type="ObservableInt"/> | ||
| 25 | + | ||
| 26 | + </data> | ||
| 27 | + | ||
| 28 | + <RelativeLayout | ||
| 29 | + android:id="@+id/test" | ||
| 30 | + android:layout_width="@{videoPortraitWidth.get(),default=@dimen/videoPortraitHeight}" | ||
| 31 | + android:layout_height="@{isUgc.get() ? LayoutParams.MATCH_PARENT : (isPortrait.get() ? videoPortraitHeight.get() : LayoutParams.MATCH_PARENT),default=@dimen/videoPortraitHeight}" | ||
| 32 | + android:background="@android:color/black"> | ||
| 33 | + | ||
| 34 | + <com.cnlive.libs.video.video.SwitchVideoView | ||
| 35 | + android:id="@+id/videoView" | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="match_parent"/> | ||
| 38 | + | ||
| 39 | + <com.cnlive.gundam.video.view.PlayerTouchView | ||
| 40 | + android:id="@+id/touchView" | ||
| 41 | + android:layout_width="match_parent" | ||
| 42 | + android:layout_height="match_parent"/> | ||
| 43 | + | ||
| 44 | + <com.cnlive.gundam.video.view.PlayerControllerView | ||
| 45 | + android:id="@+id/controllerView" | ||
| 46 | + android:layout_width="match_parent" | ||
| 47 | + android:layout_height="match_parent"/> | ||
| 48 | + | ||
| 49 | + <com.cnlive.gundam.video.view.PlayerInfoView | ||
| 50 | + android:id="@+id/infoView" | ||
| 51 | + android:layout_width="match_parent" | ||
| 52 | + android:layout_height="match_parent"/> | ||
| 53 | + | ||
| 54 | + </RelativeLayout> | ||
| 55 | + | ||
| 56 | +</layout> | ||
| 0 | \ No newline at end of file | 57 | \ No newline at end of file |
app/src/main/res/values/colors.xml
| @@ -3,4 +3,9 @@ | @@ -3,4 +3,9 @@ | ||
| 3 | <color name="colorPrimary">#3F51B5</color> | 3 | <color name="colorPrimary">#3F51B5</color> |
| 4 | <color name="colorPrimaryDark">#303F9F</color> | 4 | <color name="colorPrimaryDark">#303F9F</color> |
| 5 | <color name="colorAccent">#FF4081</color> | 5 | <color name="colorAccent">#FF4081</color> |
| 6 | + | ||
| 7 | + <color name="list_divider">#9e9e9e</color> | ||
| 8 | + | ||
| 9 | + <color name="rate_sel">#ff0000</color> | ||
| 10 | + <color name="rate_nor">#ffffff</color> | ||
| 6 | </resources> | 11 | </resources> |
app/src/main/res/values/dimens.xml
0 → 100644