Commit 955b6477 authored by Chen Jiping's avatar Chen Jiping

feat:增加视频播放状态监控

parent ef38bd4c
...@@ -120,6 +120,19 @@ class PlayView { ...@@ -120,6 +120,19 @@ class PlayView {
_this.curIndex++; _this.curIndex++;
_this.showVideo(); _this.showVideo();
}) })
const video = $("#video")[0];
//添加播放完成事件
video.addEventListener('ended', function () {
//如果当前序号大于解锁的索引,则表示解锁了新视频
if(_this.curIndex > _this.unlock){
_this.unlock = _this.curIndex;
}
// 监听视频播放结束
_this.refreshBtnStatus();
});
} }
showVideo(){ showVideo(){
...@@ -134,21 +147,22 @@ class PlayView { ...@@ -134,21 +147,22 @@ class PlayView {
$("#video").attr('src', videoArr[this.curIndex]) ; $("#video").attr('src', videoArr[this.curIndex]) ;
const video = $("#video")[0]; const video = $("#video")[0];
video.play();
video.muted = false; video.muted = false;
//video.controls = true;
_this.refreshBtnStatus(); let i = setInterval(() => {
//添加播放完成事件 if (video.readyState > 0) {
video.addEventListener('ended', function () { video.play();
//如果当前序号大于解锁的索引,则表示解锁了新视频 clearInterval(i);
if(_this.curIndex > _this.unlock){
_this.unlock = _this.curIndex;
} }
// 监听视频播放结束 }, 100);
_this.refreshBtnStatus(); _this.refreshBtnStatus();
});
} }
refreshBtnStatus(){ refreshBtnStatus(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment