|
@@ -22,6 +22,7 @@ import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.ApiJSONUtil;
|
|
import com.sheep.gamegroup.util.ApiJSONUtil;
|
|
|
import com.sheep.gamegroup.util.ApiUtil;
|
|
import com.sheep.gamegroup.util.ApiUtil;
|
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.FileUtil;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
@@ -38,6 +39,7 @@ import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack;
|
|
|
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
|
|
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
|
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
@@ -45,6 +47,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
|
|
|
|
|
+import static com.sheep.jiuyan.samllsheep.utils.ClassFileHelper.DIR;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Created by realicing on 2018/11/9.
|
|
* Created by realicing on 2018/11/9.
|
|
|
* realicing@sina.com
|
|
* realicing@sina.com
|
|
@@ -115,9 +119,14 @@ public class ActVideoDetail extends BaseUMActivity {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void initVideoData(DiscoveryVideo lastVideo) {
|
|
private void initVideoData(DiscoveryVideo lastVideo) {
|
|
|
|
|
+ String url = lastVideo.getResource();
|
|
|
|
|
+ String fileName = FileUtil.getLastSplitEnd(url, '/') + ".mp4";
|
|
|
|
|
+ String filePath = new File(DIR, fileName).getAbsolutePath();
|
|
|
|
|
+ //开始下载视频
|
|
|
|
|
+ Jump2View.getInstance().startDownloadService(url, filePath);
|
|
|
video_id = lastVideo.getId();
|
|
video_id = lastVideo.getId();
|
|
|
user_id = lastVideo.getUser_id();
|
|
user_id = lastVideo.getUser_id();
|
|
|
- video_url = lastVideo.getResource();
|
|
|
|
|
|
|
+ video_url = filePath;
|
|
|
video_title = lastVideo.getTitle();
|
|
video_title = lastVideo.getTitle();
|
|
|
video_cover_url = lastVideo.getCover();
|
|
video_cover_url = lastVideo.getCover();
|
|
|
loadVideoData(lastVideo);
|
|
loadVideoData(lastVideo);
|
|
@@ -157,7 +166,7 @@ public class ActVideoDetail extends BaseUMActivity {
|
|
|
.setShowFullAnimation(false)
|
|
.setShowFullAnimation(false)
|
|
|
.setNeedLockFull(true)
|
|
.setNeedLockFull(true)
|
|
|
.setUrl(getVideoUrl())
|
|
.setUrl(getVideoUrl())
|
|
|
- .setCacheWithPlay(true)
|
|
|
|
|
|
|
+ .setCacheWithPlay(false)
|
|
|
.setVideoTitle(getVideoTitle())
|
|
.setVideoTitle(getVideoTitle())
|
|
|
.setVideoAllCallBack(new GSYSampleCallBack() {
|
|
.setVideoAllCallBack(new GSYSampleCallBack() {
|
|
|
@Override
|
|
@Override
|
|
@@ -172,6 +181,35 @@ public class ActVideoDetail extends BaseUMActivity {
|
|
|
super.onAutoComplete(url, objects);
|
|
super.onAutoComplete(url, objects);
|
|
|
videoPlayer.startPlayLogic();
|
|
videoPlayer.startPlayLogic();
|
|
|
}
|
|
}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onPlayError(String url, Object... objects) {
|
|
|
|
|
+ super.onPlayError(url, objects);
|
|
|
|
|
+ File file = new File(video_url);
|
|
|
|
|
+ long curPosition = GSYVideoManager.instance().getCurPlayerManager().getCurrentPosition();
|
|
|
|
|
+ LogUtil.println("initPlay", "onPlayError", url, curPosition);
|
|
|
|
|
+ if(file.exists()){
|
|
|
|
|
+ LogUtil.println("initPlay", "retry play");
|
|
|
|
|
+ if (videoPlayer != null) {
|
|
|
|
|
+ if(curPosition > 0) {
|
|
|
|
|
+ videoPlayer.setSeekOnStart(curPosition);
|
|
|
|
|
+ videoPlayer.startPlayLogic();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ViewUtil.delay(new AbsObserver<Integer>(){
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(Integer integer) {
|
|
|
|
|
+ super.onNext(integer);
|
|
|
|
|
+ try {
|
|
|
|
|
+ if(videoPlayer != null)
|
|
|
|
|
+ videoPlayer.startPlayLogic();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}).build(videoPlayer);
|
|
}).build(videoPlayer);
|
|
|
isInit = true;
|
|
isInit = true;
|
|
|
} else {
|
|
} else {
|