8
8
import androidx .lifecycle .Observer ;
9
9
import androidx .lifecycle .ViewModelProvider ;
10
10
11
- import com .dueeeke .videocontroller .component .GestureView ;
12
- import com .dueeeke .videoplayer .player .VideoView ;
11
+ import xyz .doikki .videocontroller .component .GestureView ;
12
+ import xyz .doikki .videoplayer .player .ProgressManager ;
13
+ import xyz .doikki .videoplayer .player .VideoView ;
14
+
13
15
import com .github .tvbox .osc .R ;
14
16
import com .github .tvbox .osc .base .BaseActivity ;
15
17
import com .github .tvbox .osc .bean .VodInfo ;
18
+ import com .github .tvbox .osc .cache .CacheManager ;
16
19
import com .github .tvbox .osc .event .RefreshEvent ;
17
20
import com .github .tvbox .osc .player .controller .BoxVideoController ;
18
21
import com .github .tvbox .osc .player .controller .BoxVodControlView ;
19
22
import com .github .tvbox .osc .ui .dialog .ParseDialog ;
20
23
import com .github .tvbox .osc .util .HawkConfig ;
24
+ import com .github .tvbox .osc .util .MD5 ;
21
25
import com .github .tvbox .osc .util .PlayerHelper ;
22
26
import com .github .tvbox .osc .viewmodel .SourceViewModel ;
23
27
import com .orhanobut .hawk .Hawk ;
@@ -101,6 +105,20 @@ public void playPre() {
101
105
controller .setCanChangePosition (true );
102
106
controller .setEnableInNormal (true );
103
107
controller .setGestureEnabled (true );
108
+ mVideoView .setProgressManager (new ProgressManager () {
109
+ @ Override
110
+ public void saveProgress (String url , long progress ) {
111
+ CacheManager .save (MD5 .string2MD5 (url ), progress );
112
+ }
113
+
114
+ @ Override
115
+ public long getSavedProgress (String url ) {
116
+ if (CacheManager .getCache (MD5 .string2MD5 (url )) == null ) {
117
+ return 0 ;
118
+ }
119
+ return (long ) CacheManager .getCache (MD5 .string2MD5 (url ));
120
+ }
121
+ });
104
122
mVideoView .setVideoController (controller );
105
123
}
106
124
@@ -111,6 +129,7 @@ private void initViewModel() {
111
129
public void onChanged (JSONObject object ) {
112
130
showSuccess ();
113
131
if (object != null && object .optString ("key" , "" ).equals (parseKey )) {
132
+ String progressKey = object .optString ("proKey" , null );
114
133
parseDialog .parse (sourceKey , object , new ParseDialog .ParseCallback () {
115
134
@ Override
116
135
public void success (String playUrl , Map <String , String > headers ) {
@@ -119,6 +138,7 @@ public void success(String playUrl, Map<String, String> headers) {
119
138
public void run () {
120
139
if (mVideoView != null ) {
121
140
mVideoView .release ();
141
+ mVideoView .setProgressKey (progressKey );
122
142
if (headers != null ) {
123
143
mVideoView .setUrl (playUrl , headers );
124
144
} else {
@@ -284,6 +304,7 @@ public void onBack() {
284
304
285
305
parseKey = vs .url ;
286
306
showLoading ();
287
- sourceViewModel .getPlay (sourceKey , mVodInfo .playFlag , vs .url );
307
+ String progressKey = mVodInfo .sourceKey + mVodInfo .playFlag + mVodInfo .playIndex ;
308
+ sourceViewModel .getPlay (sourceKey , mVodInfo .playFlag , progressKey , vs .url );
288
309
}
289
310
}
0 commit comments