视频器拖动调整

This commit is contained in:
joshen
2024-06-20 14:25:28 +08:00
parent 6a51913f60
commit a7c041b010
3 changed files with 309 additions and 35 deletions

View File

@@ -11,6 +11,7 @@
<view style="position: relative;">
<video-player
:url="blobUrl"
:blobId="blobId"
controls
:enable-play-gesture="true"
:inittime="curContent.lastStudyTime"
@@ -20,7 +21,6 @@
@timeupdate="onPlayerPlaying"
@fullscreenchange="onFullScreen"
:drag="curriculumData.isDrag"
@progress="progress"
style="width: 100%; object-fit: fill">
></video-player>
<view class="player-box" v-if="playerBoxShow">
@@ -428,9 +428,6 @@
export default {
data(){
return{
progressData: 0,
contentTypeV: '',
trueFalse: true,
loading:false,//加载中
courseId:'',//当前课程的id
studyId: '',//当前学习的id
@@ -486,6 +483,7 @@
appentInterval:15,//追加学习时间的间隔 3秒加一次
preTime:-1,
blobUrl:'',//音视频的播放地址
blobId: '',
localTimeKey:'boeu-study-time' ,//本地存储的学习时长的key json格式
localTimeValue:0,//计算的时间
appendStudyOtherHandle:null,
@@ -630,7 +628,6 @@
let $this=this;
uni.showLoading({title:'加载中...'})
apiCourseStudy.studyIndex(this.courseId).then(rs=>{
// this.courseType = rs.result.course.type
if(rs.status != 200) {
uni.hideLoading();
uni.showToast({title:rs.message,type:'fail'});
@@ -777,6 +774,22 @@
});
},
playContent(con,conIndex,catIndex){
// 视频设置禁用处理逻辑,如果用户已全部观看完该视频则设置为能全部拖动的逻辑把isDrag设置为true即可,同时删除本地存储的数据
// if(con.progressVideo ===1){
// var obj = JSON.parse(con.content)
// obj.isDrag = true
// con.content = JSON.stringify(obj)
// var time = localStorage.getItem('videoProgressData')
// var arr = time&&JSON.parse(time) || {}
// alert(con.progressVideo+'--'+con.id + '--'+JSON.stringify(arr))
// delete arr[con.id];
// localStorage.setItem('videoProgressData',JSON.stringify(arr))
// }
console.log('更换播放内容 playContent::',con,conIndex,catIndex)
//对于需要控制学习顺序的
if(conIndex!=undefined && catIndex!=undefined) {
if(this.courseInfo.orderStudy) {
@@ -798,6 +811,7 @@
}
}
}
//切换播放内容
this.changePlayRes(con);
},
@@ -884,7 +898,6 @@
//this.curContent=0;
// console.log(con,'con');
this.playerBoxShow=false;
this.contentTypeV = con.contentType
if(con.contentType==40){
//如果是文档需要再次加载pdf
if(con.content!='' && con.content.indexOf('.pdf')==-1){
@@ -936,13 +949,16 @@
location.href=this.conLink.url
}
} else if(con.contentType==10 || con.contentType==20) {
if(con.content.startsWith('\{')){
this.curriculumData=JSON.parse(con.content);
var d = JSON.parse(con.content)
if(d.url=="/course/2024/4/1224670812274712576.mp4") d.isDrag = false
this.curriculumData=d;
}else{
this.curriculumData.url=con.content;
}
console.log('this.curriculumData:::',this.curriculumData)
this.blobUrl=this.fileBaseUrl+this.curriculumData.url;
this.blobId = con.id
//console.log(this.blobUrl,'this.blobUrl');
}
//console.log(con.contentType,'con.contentType');
@@ -1300,9 +1316,6 @@
//console.log(e);
this.scrollInfo = e.detail;
},
progress(val) {
this.progressData = (val).toFixed(2);
},
//以下是播放相关的处理
saveStudyDuration(duration) { //保存本地存储的学习时长
if (duration > 0) {
@@ -1319,12 +1332,8 @@
"objInfo": ""+this.courseInfo.name,
"aid":this.userInfo.aid, //当前登录人的id
"aname":this.userInfo.name,//当前人的姓名
"status": 1, //状态
"contentId": this.curContent.id,
"status": 1 //状态
}
if(this.contentTypeV == 10) {
postData.progress = this.progressData
}
//静默处理
apiStat.sendEvent(postData).then(rs=>{
if(rs.status == 200) {
@@ -1538,20 +1547,6 @@
}
},
onPlayerPlaying(e){
if(e.detail.currentTime > 2 && this.trueFalse){
let params ={
studyId: this.studyId,//学习id,
courseId: this.courseId,//课程id,
contentId: this.curContent.id,//内容id,
contentType: this.curContent.contentType,
contentName: this.curContent.contentName,//内容名称
progress: 1,
status: 2,
contentTotal:this.totalContent
}
apiCourseStudy.studyContent(params)
this.trueFalse = false
}
//console.log("当前播放11",itme);
//console.log("当前播放11"+itme);
let intTime=parseInt(e.detail.currentTime);
@@ -1591,6 +1586,18 @@
itemId:this.curContent.studyItemId,
videoTime:intTime
}
//alert(3+'--'+this.curriculumData.isDrag +'---'+this.curContent.progressVideo)
if(!this.curriculumData.isDrag && this.curContent.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.curContent.id
postData.courseId = this.curContent.courseId
}
}
apiCourseStudy.studyVideoTime(postData).then(rs=>{
if(rs.status!=200){
console.log('记录播放时间错误');
@@ -1662,6 +1669,15 @@
itemId:this.curContent.studyItemId,
videoTime:intTime
}
if(!this.curriculumData.isDrag && this.curContent.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.curContent.id
postData.courseId = this.curContent.courseId
}
}
apiCourseStudy.studyVideoTime(postData).then(rs=>{
if(rs.status!=200){
console.log('记录播放时间错误');