From 18092b9a0b366f175822f6086840b2363c783e9d Mon Sep 17 00:00:00 2001 From: nisen Date: Tue, 21 Nov 2023 10:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=AD=E6=94=BE=E8=A7=86=E9=A2=91=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E8=A7=86=E9=A2=91=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E8=AE=A1=E6=97=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/VideoPlayer/index.vue | 17 +++++++++++++++++ src/views/study/coursenew.vue | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/VideoPlayer/index.vue b/src/components/VideoPlayer/index.vue index 55f7f6c9..922e3ab9 100644 --- a/src/components/VideoPlayer/index.vue +++ b/src/components/VideoPlayer/index.vue @@ -22,6 +22,8 @@ tabindex="0" width="100%" height="100%" + @waiting="onWaiting" + @playing="onPlaying" > @@ -358,6 +360,20 @@ export default { }); }, methods: { + //当视频由于需要缓冲下一帧而停止,解决一直计时的问题 + onWaiting(){ + console.log('触发了onWairing'); + this.$emit('onPlayerEnded', {}) + }, + //当音频/视频在已因缓冲而暂停或停止后已就绪时 + onPlaying(){ + console.log('触发缓存结束onPlaying'); + if(this.videoDom.paused){ + this.$emit('onPlayerEnded', {}) + }else{ + this.$emit('onPlayerPlay', {}); + } + }, /* 切换播放状态 */ togglePlayStatus() { @@ -372,6 +388,7 @@ export default { this.isPlaying = true; this.isInit = true; this.$emit('onPlayerPlay', {});//播放(播放时会调用) + console.log('播放'); } else { this.videoDom.pause(); this.isPlaying = false; diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index 06457d30..a15c90df 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -1477,10 +1477,10 @@ //如果当前追加开始时间不为空 let now = new Date(); let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数 - console.log(m/1000,'时间'); + // console.log(m/1000,'时间'); let sen = Math.round(m / 1000); //计算秒数 - console.log('定时器时间',sen); + // console.log('定时器时间',sen); // 每次添加的是定时器计时的时间 duration = duration + sen;//追加的是秒 if (duration >= 60) { //一分钟保存一次