From 15f11ae4c91a64e71fadad48ec18e40e337a043d Mon Sep 17 00:00:00 2001 From: joshen <445497689@qq.com> Date: Wed, 19 Jun 2024 17:44:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=A6=81=E7=94=A8=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/VideoPlayer/index.vue | 52 +++++--- src/components/VideoPlayer/progress-bar.vue | 36 +++--- src/views/course/ManageList.vue | 2 +- src/views/study/coursenew.vue | 125 +++++++++++++------- 4 files changed, 137 insertions(+), 78 deletions(-) diff --git a/src/components/VideoPlayer/index.vue b/src/components/VideoPlayer/index.vue index e70d31b7..49443911 100644 --- a/src/components/VideoPlayer/index.vue +++ b/src/components/VideoPlayer/index.vue @@ -74,6 +74,7 @@ :currentProgress="currentProgress" v-on:updateProgress="updateProgressByClickBar" v-on:getMouseDownStatus="getMouseDownStatusOfProgressBar" + :blobId="blobId" :isDrag="isDrag" width="100%" height="4px" @@ -241,6 +242,11 @@ export default { type: String, default: null, }, + // 视频链接对应的content Id + blobId: { + type: String, + default: null, + }, // 主题色 primaryColor: { type: String, @@ -316,13 +322,14 @@ export default { if (this.isPlaying && !this.isMousedownProgress) { 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)) + // 视频播放时本地记录视频实时播放时长,视频设置了禁止拖动时执行 + if(!this.isDrag){ + var time = localStorage.getItem('videoProgressData') + var arr = time&&JSON.parse(time) || {} + if(arr[this.blobId] < this.currentProgress || !arr[this.blobId]){ + arr[this.blobId] = parseFloat(this.currentProgress.toFixed(8)) + if(arr[this.blobId]) localStorage.setItem('videoProgressData',JSON.stringify(arr)) + } } // 定时更新进度的文字显示 @@ -440,7 +447,16 @@ export default { // 禁止拖拽视频前进时,未观看视频不让前进播放 if(!this.isDrag){ var time = localStorage.getItem('videoProgressData') - if(time && parseFloat(time) * this.videoDom.duration{ if(rs.status==200){ diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index c19b48be..610028ba 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -27,7 +27,7 @@
- @@ -384,6 +384,7 @@ studyId: '', //当前学习的id initContentId: '', //初始化当前学习的内容节 blobUrl: '', //播放的文件地址,新添加,采用blob方式 + blobId: '', //播放的文件地址,对应的contents ID contentData: { studyItemId: '', status: 1 @@ -672,6 +673,8 @@ //let url=process.env.VUE_APP_BASE_API+'/xboe/m/course/file/show?cf='+this.curriculumData.url; //let url=this.fileBaseUrl+this.curriculumData.url; this.createPlayUrl(r.contentRefId, this.curriculumData.url); + + this.blobId = r.id } else if (r.contentType == 40) { // if (r.content != '' && r.content.indexOf('.pdf') == -1) { apiCourseFile.detail(r.contentRefId).then(cfrs => { @@ -797,6 +800,19 @@ if(!this.isCrowd){ return } + // 视频设置禁用处理逻辑,如果用户已全部观看完该视频,则设置为能全部拖动的逻辑,把isDrag设置为true即可,同时删除本地存储的数据 + if(r.progressVideo ===1){ + var obj = JSON.parse(r.content) + obj.isDrag = true + r.content = JSON.stringify(obj) + + var time = localStorage.getItem('videoProgressData') + var arr = time&&JSON.parse(time) || {} + delete arr[r.id]; + localStorage.setItem('videoProgressData',JSON.stringify(arr)) + + } + if (i != undefined && i!=-1 && index != undefined && r.status < 9) { if (this.courseInfo.orderStudy) { //判断上个是否学完 @@ -841,6 +857,9 @@ } } this.changePlayRes(r,item); + console.log('r, i, index,item::',r, i, index,item) + this.videoIndex = i + this.blobId = r.id }, loadScorePraiseAndTrample() { //加载是否请过分 @@ -904,9 +923,9 @@ this.interactRuning = true; let teacherId=''; if(this.teachers.length>0){ - teacherId=this.teachers[0].teacherId; + teacherId=this.teachers[0].teacherId; }else{ - teacherId=this.courseInfo.sysCreateAid + teacherId=this.courseInfo.sysCreateAid } let postData = { objType: 1, @@ -1120,16 +1139,39 @@ } else { var markDiv = div.querySelector("#" + divId); if (markDiv) { - div.removeChild(markDiv); + div.removeChild(markDiv); } } }, + // 视频播放结束时执行调用 studyVideoTime + EndedstudyVideoTime(){ + let postData = { + itemId: this.contentData.studyItemId, + videoTime: this.contentData.lastStudyTime + } + console.log('this.curriculumData 111::',this.curriculumData,this.contentData.id) + if(!this.curriculumData.isDrag && this.contentData.progressVideo !=1){ + var time = localStorage.getItem('videoProgressData') + var arr = time&&JSON.parse(time) || {} + if(arr[this.blobId]) { + postData.progressVideo = arr[this.blobId] + postData.contentId = this.contentList[this.videoIndex].id + postData.courseId = this.contentList[this.videoIndex].courseId + } + } + apiStudy.studyVideoTime(postData).then(rs => { + if (rs.status != 200) { + console.log('记录播放时间错误'); + } + }); + }, onPlayerPause() { //console.log("暂停"); this.stopStudyTime(); }, onPlayerEnded() { this.playerBoxShow = true; + this.EndedstudyVideoTime() this.stopStudyTime(); if(this.contentData.status < 9) { this.finishStudyItem(); @@ -1167,23 +1209,24 @@ if (intTime > 10 && intTime != this.contentData.lastStudyTime && saveTime == 0 && this.contentData .studyItemId != '') { this.contentData.lastStudyTime = intTime; - let postData = { - itemId: this.contentData.studyItemId, - videoTime: intTime - }; - var time = localStorage.getItem('videoProgressData') - var arr = time&&JSON.parse(time) || {} - if(arr[this.blobUrl]) { - postData.progressVideo = arr[this.blobUrl] - postData.contentId = this.contentList[this.videoIndex].id - postData.courseId = this.contentList[this.videoIndex].courseId - } - //console.log('记录播放时间') - apiStudy.studyVideoTime(postData).then(rs => { - if (rs.status != 200) { - console.log('记录播放时间错误'); - } - }); + this.EndedstudyVideoTime() + // let postData = { + // itemId: this.contentData.studyItemId, + // videoTime: intTime + // }; + // var time = localStorage.getItem('videoProgressData') + // var arr = time&&JSON.parse(time) || {} + // if(arr[this.blobId] && !this.isDrag) { + // postData.progressVideo = arr[this.blobId] + // postData.contentId = this.contentList[this.videoIndex].id + // postData.courseId = this.contentList[this.videoIndex].courseId + // } + // //console.log('记录播放时间') + // apiStudy.studyVideoTime(postData).then(rs => { + // if (rs.status != 200) { + // console.log('记录播放时间错误'); + // } + // }); } } }, @@ -1215,23 +1258,24 @@ if (intTime > 10 && intTime != this.contentData.lastStudyTime && saveTime == 0 && this.contentData .studyItemId) { this.contentData.lastStudyTime = intTime; - let postData = { - itemId: this.contentData.studyItemId, - videoTime: intTime - }; - var time = localStorage.getItem('videoProgressData') - var arr = time&&JSON.parse(time) || {} - if(arr[this.blobUrl]) { - postData.progressVideo = arr[this.blobUrl] - postData.contentId = this.contentList[this.videoIndex].id - postData.courseId = this.contentList[this.videoIndex].courseId - } - //console.log('记录播放时间') - apiStudy.studyVideoTime(postData).then(rs => { - if (rs.status != 200) { - console.log('记录播放时间错误'); - } - }); + this.EndedstudyVideoTime() + // let postData = { + // itemId: this.contentData.studyItemId, + // videoTime: intTime + // }; + // var time = localStorage.getItem('videoProgressData') + // var arr = time&&JSON.parse(time) || {} + // if(arr[this.blobId] && !this.isDrag) { + // postData.progressVideo = arr[this.blobId] + // postData.contentId = this.contentList[this.videoIndex].id + // postData.courseId = this.contentList[this.videoIndex].courseId + // } + // //console.log('记录播放时间') + // apiStudy.studyVideoTime(postData).then(rs => { + // if (rs.status != 200) { + // console.log('记录播放时间错误'); + // } + // }); } }, audioPlay() { @@ -1386,7 +1430,6 @@ } }); }); - if (this.courseInfo.type == 10) { ///console.log(this.contentList[0],'ccccc11111') this.showRes(this.contentList[0]); @@ -1396,12 +1439,12 @@ // this.showRes(this.contentList[0]); //console.log(this.catalogTree,'ccccc22222') this.showRes(this.catalogTree[0].children[0]) - this.videoIndex = 0 } else { //console.log(this.contentList[0],'ccccc3333') this.showRes(this.contentList[playIndex]); - this.videoIndex = playIndex + //this.videoIndex = playIndex } + this.videoIndex = playIndex } }, saveScormStudy() {