视频禁用拖动修改

This commit is contained in:
joshen
2024-06-19 17:44:44 +08:00
parent 5e3b122984
commit 15f11ae4c9
4 changed files with 137 additions and 78 deletions

View File

@@ -27,7 +27,7 @@
<course-image v-if="courseInfo.id != ''" :course="courseInfo"></course-image>
</div>
<div v-if="resType == 10" style="position: relative;">
<videoPlayer ref="myVideoPlayer" id="myVideoPlayer" @progress="progress" :src="blobUrl" @onPlayerPlaying="onPlayerPlaying"
<videoPlayer ref="myVideoPlayer" id="myVideoPlayer" @progress="progress" :src="blobUrl" :blobId="blobId" @onPlayerPlaying="onPlayerPlaying"
:initTime="contentData.lastStudyTime" :notePlay="notePlay" @onPlayerPlay="onPlayerPlay"
:isDrag="curriculumData.isDrag" @onFullscreen="onFullscreen" @onPlayerPause="onPlayerPause"
@onPlayerEnded="onPlayerEnded" :isCrowd="isCrowd" @onTimeUpdate="handleAudioTimeUpdate"></videoPlayer>
@@ -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() {