|
@@ -45,6 +45,7 @@ import static com.hc.webapp.web.AndroidToJS.JS_EVENT_PLAY_START;
|
|
|
public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayersdk.iICntvPlayInterface, IVideoPlayer, Runnable {
|
|
|
|
|
|
private static final int TIME = 10 * 1000;
|
|
|
+ String TAG ="YSTVideoPlayer";
|
|
|
|
|
|
// 计时器
|
|
|
// private Timer timer_pay;
|
|
@@ -76,6 +77,8 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
private TimerTask timerTask;
|
|
|
|
|
|
|
|
|
+ private boolean isSeeking = false; //当前是否在拖动滑动条,此过程中不允许暂停视频
|
|
|
+
|
|
|
//本地存储
|
|
|
private LastPlayTimeStore lastPlayTimeStore; //本地数据库储存对象
|
|
|
private String mLastPlayTime = ""; //临时存储上次播放位置
|
|
@@ -198,6 +201,7 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
* CNTV播放器初始化并播放视频
|
|
|
*/
|
|
|
public void setData(@NonNull VideoData data,Context context) {
|
|
|
+ isSeeking = false;
|
|
|
lastPlayTimeStore = new LastPlayTimeStore(context);
|
|
|
this.context = context;
|
|
|
this.videoData = data;
|
|
@@ -220,9 +224,11 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
AndroidToJS.evaluateJavascript(webView, String.format(JS_EVENT_PLAY_START, 0, e.getMessage()));
|
|
|
Logger.e("视频初始化完成但是异常%s", e);
|
|
|
}
|
|
|
+ lastPlayTimeStore.delete(videoData.getId());
|
|
|
}
|
|
|
|
|
|
private void setVideoData(VideoData data){
|
|
|
+ hasCompletion = false;
|
|
|
IcntvPlayerInfo icntvPlayerInfo = new IcntvPlayerInfo(); //播放器所需传入参数实例
|
|
|
icntvPlayerInfo.setPlayUrl(data.getUrl());
|
|
|
icntvPlayerInfo.setApp_id(data.getAppId());
|
|
@@ -320,7 +326,7 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
resumePlay();
|
|
|
}else{
|
|
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
- if(icntvPlayer.isPlaying()){
|
|
|
+ if(icntvPlayer.isPlaying() && !isSeeking ){
|
|
|
pauseOrPlay(false);
|
|
|
}
|
|
|
}
|
|
@@ -328,7 +334,7 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
break;
|
|
|
case KeyEvent.KEYCODE_ENTER:
|
|
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
- if(icntvPlayer.isPlaying()){
|
|
|
+ if(icntvPlayer.isPlaying() && !isSeeking ){
|
|
|
pauseOrPlay(false);
|
|
|
}
|
|
|
}
|
|
@@ -349,6 +355,7 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
if (icntvPlayer == null) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
if (!play && icntvPlayer.isPlaying()) {
|
|
|
onVideoPause();
|
|
|
playOrPause.setImageResource(R.drawable.btn_icon_stop);
|
|
@@ -441,7 +448,12 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
|
|
|
@Override
|
|
|
public void restart() {
|
|
|
+ isSeeking = false;
|
|
|
+ lastPlayTimeStore.delete(videoData.getId());
|
|
|
+ mLastPlayTime = "0";
|
|
|
+ videoData.setLastTimePosition(0);
|
|
|
onVideoResume();
|
|
|
+ hasCompletion = false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -450,7 +462,9 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
lastPlayBar.setVisibility(INVISIBLE);
|
|
|
isShowLastPlayBar = false;
|
|
|
}else{
|
|
|
- pauseOrPlay(false);
|
|
|
+ if(icntvPlayer.isPlaying() && !isSeeking ){
|
|
|
+ pauseOrPlay(false);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -478,7 +492,11 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
|
|
|
//切换视频
|
|
|
public void switchVideo(VideoData videoData) {
|
|
|
+ isSeeking = false;
|
|
|
this.videoData = videoData;
|
|
|
+ if(videoTitle != null){
|
|
|
+ videoTitle.setText(videoData.getTitle());
|
|
|
+ }
|
|
|
setVideoData(videoData);
|
|
|
showControlWidget(true);
|
|
|
}
|
|
@@ -556,6 +574,7 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
if(timer == null){
|
|
|
timer = new Timer();
|
|
|
}
|
|
|
+ isSeeking = true;
|
|
|
timerTask = new TimerTask() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -563,6 +582,9 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
+ if(hasCompletion){
|
|
|
+ return;
|
|
|
+ }
|
|
|
long myCurrentTime = Calendar.getInstance().getTimeInMillis();
|
|
|
if(myCurrentTime - seekCurrentTime > 3){
|
|
|
int position = seekByTvBar.getProgress();
|
|
@@ -571,6 +593,7 @@ public class YSTVideoPlayer extends FrameLayout implements tv.icntv.icntvplayers
|
|
|
float fDuration = duration;
|
|
|
position = (int)(fPostion*fDuration/1000);
|
|
|
seekTo(position);
|
|
|
+ isSeeking = false;
|
|
|
seekContainer.setVisibility(GONE);
|
|
|
}
|
|
|
}
|