学员端视频播放器逻辑调整

This commit is contained in:
joshen
2024-06-18 14:22:11 +08:00
parent e860454a2a
commit 5e3b122984
4 changed files with 153 additions and 22 deletions

View File

@@ -314,9 +314,17 @@ export default {
setInterval(() => {
// 定时更新进度条
if (this.isPlaying && !this.isMousedownProgress) {
this.currentProgress =
this.videoDom.currentTime / this.videoDom.duration;
this.currentProgress = this.videoDom.currentTime / this.videoDom.duration;
}
// 视频播放时本地记录视频实时播放时长
// console.log(this.src,this.currentProgress,'定时更新进度条');
var time = localStorage.getItem('videoProgressData')
var arr = time&&JSON.parse(time) || {}
if(arr[this.src] < this.currentProgress || !arr[this.src]){
arr[this.src] = this.currentProgress
localStorage.setItem('videoProgressData',JSON.stringify(arr))
}
// 定时更新进度的文字显示
this.updateProgressText();
// 音量提示面板的定时隐藏
@@ -349,7 +357,7 @@ export default {
// 根据视频的readyState判断下一帧是否已加载并控制loading的显示
this.isShowLoading = this.videoDom.readyState < 3;
//if()
//console.log(this.videoDom.readyState,'this.videoDom.readyState');
// console.log(this.videoDom.readyState,'视频播放');
}, 1000);
// 视频dom监听器用于控制鼠标的显示
this.videoDom.addEventListener("mousemove", () => {
@@ -429,6 +437,13 @@ export default {
*/
forwardCurrentTime() {
let newCurrentTime = this.videoDom.currentTime + this.timeFastBack;
// 禁止拖拽视频前进时,未观看视频不让前进播放
if(!this.isDrag){
var time = localStorage.getItem('videoProgressData')
if(time && parseFloat(time) * this.videoDom.duration<newCurrentTime){
return
}
}
this.videoDom.currentTime = newCurrentTime;
this.barrageTimelineStart = newCurrentTime;
this.updateProgressBySetTime(newCurrentTime);
@@ -554,6 +569,10 @@ export default {
},
//开始播放
startPlay:function(newTime){
// console.log('开始播放::',newTime)
// window.playVideoInterTime = setInterval(()=>{
// console.log('视频播放:',newTime)
// },2000)
if(newTime){
this.videoDom.currentTime = newTime;
this.barrageTimelineStart = newTime;
@@ -576,7 +595,6 @@ export default {
// 进度条到终点时修改播放状态
this.isShowPlayer = false
this.$emit('onPlayerPlaying', this.videoDom.currentTime,this.videoDom.duration)
this.$emit('progress',this.currentProgress)
if (this.currentProgress === 1) {
this.isPlaying = false;
this.$emit('onPlayerEnded', {})
@@ -592,7 +610,6 @@ export default {
src: function () {
// 当视频地址变更时,重载视频
this.videoDom.load();
this.isPlaying = false
},
},
};