diff --git a/pages/application/onlinexxks/video_study.vue b/pages/application/onlinexxks/video_study.vue index 03b4b3f..cc28a1a 100644 --- a/pages/application/onlinexxks/video_study.vue +++ b/pages/application/onlinexxks/video_study.vue @@ -114,6 +114,7 @@ import {basePath, loginUser, baseImgPath} from "@/common/tool"; let faceAuthTimer; // 人脸认证计时器 let throttleTimer; let throttleFlag; +let videoContext; export default { data() { return { @@ -141,7 +142,8 @@ export default { videoSrc: "", // 视频地址 videoPoster: "", // 视频封面图 scrollHeight: '0px', // scroll-view减去的高度 - videoContext: null, // 视频上下文 + // videoContext: null, // 视频上下文 + submitTimeWaitForCount: 0, // 提交时间等待次数 verification:false,// 是否人脸认证 } }, @@ -325,7 +327,8 @@ export default { this.videoList = resData.pd.VIDEOLIST; }, async fnVideoSwitching(videoData, hasNodes, index, index1) { - this.videoContext && this.videoContext.pause(); + videoContext && videoContext.pause(); + this.submitTimeWaitForCount = 0; if (this.changeVideoPlayTime !== 0) { await this.fnSubmitPlayTime("0", this.changeVideoPlayTime); this.changeVideoPlayTime = 0; @@ -361,10 +364,9 @@ export default { if (!resData.pd.RESOURCETIME) { await this.fnSubmitPlayTime("0", 0); } - this.serverVideoPlayTime = - resData.pd.RESOURCETIME > 10 - ? Math.floor(resData.pd.RESOURCETIME - 10) - : 0; + console.log('resData.pd.RESOURCETIME:'+resData.pd.RESOURCETIME) + this.serverVideoPlayTime = Math.floor(resData.pd.RESOURCETIME) || 0 + console.log('this.serverVideoPlayTime:'+this.serverVideoPlayTime) if (this.ISFACE === "1") { if (this.verification) { this.fnCreateVideo(); @@ -376,26 +378,45 @@ export default { } }, fnCreateVideo() { - if (!this.videoContext) { - this.videoContext = uni.createVideoContext("video"); - } - this.videoContext.play(); - this.serverVideoPlayTime !== 0 && this.videoContext.seek(this.serverVideoPlayTime); + videoContext = null; + videoContext = uni.createVideoContext("video"); + videoContext.play(); + console.log('fnCreateVideo:'+this.serverVideoPlayTime) + this.serverVideoPlayTime !== 0 && videoContext.seek(this.serverVideoPlayTime); }, - fnTimeUpdate(event) { - this.throttle(async () => { + async fnTimeUpdate(event) { const currentTime = event.detail.currentTime; if (currentTime - this.serverVideoPlayTime >= 10) { uni.navigateBack(); return; } + //app视频自带bug,判断当前视频进度与服务器进度差,如果小于10秒,则退出重新进 + if(currentTime !== 0 && Math.abs(currentTime - this.serverVideoPlayTime) > 10) { + videoContext.pause(); + uni.showModal({ + title: "提示", + content: "app开发环境问题,偶现当前视频进度获取不准确,为了防止进度被覆盖,请退出重新进入!", + showCancel:false, + success: (res) => { + uni.navigateBack(); + return; + }, + }); + } this.changeVideoPlayTime = currentTime; if (currentTime - this.serverVideoPlayTime >= 5) { + this.serverVideoPlayTime = currentTime; + this.submitTimeWaitForCount = ++this.submitTimeWaitForCount; + } + if (this.submitTimeWaitForCount === 6) { + this.submitTimeWaitForCount = 0; await this.fnSubmitPlayTime("0", currentTime); } - }, 1000); }, async fnSubmitPlayTime(IS_END, RESOURCETIME) { + if(!this.videoData.VIDEOCOURSEWARE_ID) { + return + } const resData = await this.post('/app/coursestudyvideorecord/save',{ USERNAME: loginUser.NAME, VIDEOCOURSEWARE_ID: this.videoData.VIDEOCOURSEWARE_ID, @@ -442,7 +463,7 @@ export default { this.videoList[this.firstIndex].percent = percent; } if (resData.pd.CANEXAM === "1") { - this.videoContext.pause(); + videoContext.pause(); uni.showModal({ title: "提示", content: "当前班级内所有课程均已学完,是否直接参加考试?", @@ -450,20 +471,27 @@ export default { cancelButtonText: "否", success: (res) => { if (res.confirm) { + if (videoContext && videoContext.fullScreen) { + videoContext.exitFullScreen() + } uni.navigateTo({ url: '/pages/application/onlinexxks/course_exam?STAGEEXAMPAPERINPUT_ID=' + resData.paper.STAGEEXAMPAPERINPUT_ID + '&STAGEEXAMPAPER_ID=' + resData.paper.STAGEEXAMPAPERINPUT_ID + '&CLASS_ID=' + this.CLASS_ID + '&POST_ID=' + resData.pd.POST_ID + '&STUDENT_ID=' + this.STUDENT_ID + '&NUMBEROFEXAMS=' + resData.pd.NUMBEROFEXAMS + '&entrySite=video_study' }) } else if (res.cancel) { - this.videoContext.play(); + videoContext.play(); } }, }); } }, fnEnded() { + if (this.changeVideoPlayTime - this.serverVideoPlayTime >= 10) { + uni.navigateBack(); + return; + } this.changeVideoPlayTime = 0; this.fnSubmitPlayTime("1", 0); - this.videoContext.pause(); + videoContext.pause(); this.fnClearInterval(); }, fnPlay() { @@ -474,6 +502,7 @@ export default { } faceAuthTimer = setInterval(async () => { if (new Date().getTime() >= this.randomTime) { + this.randomTime = 0; await this.fnSubmitPlayTime("0", this.changeVideoPlayTime); await this.fnNavigationFaceAuth(); } @@ -496,6 +525,9 @@ export default { CHAPTER_ID: this.videoData.CHAPTER_ID, VIDEOCOURSEWARE_ID: this.videoData.VIDEOCOURSEWARE_ID, }) + if (videoContext && videoContext.fullScreen) { + videoContext.exitFullScreen() + } const resData = await this.post('/app/user/getUserFace', { USERNAME: loginUser.NAME, USER_ID: loginUser.USER_ID,