修改正常音视频计时

This commit is contained in:
nisen
2023-11-23 14:36:41 +08:00
parent f0d00efd5e
commit 92362a0749

View File

@@ -478,7 +478,7 @@
appendStartTime: null, //记录追加的开始时间
appendHandle:null,//追加学习时长的timeout句柄
appentId:'',//当前追加的学习时长的id
appentInterval:5000,//追加学习时间的间隔 3秒加一次
appentInterval:15,//追加学习时间的间隔 3秒加一次
preTime:-1,
blobUrl:'',//音视频的播放地址
localTimeKey:'boeu-study-time' ,//本地存储的学习时长的key json格式
@@ -1334,6 +1334,12 @@
},
//追加学习时长, flag是否提交到后台
appendStudyTime() {
// 暂停的时候重新从十五秒开始
if(!this.appendStartTime){
this.appentInterval = 15
}
//重新覆盖时间
this.appendStartTime = new Date();
//console.log('开始追加学习时长',this.isAppendTime);
if (this.studyId == '') {
return;
@@ -1346,43 +1352,67 @@
window.clearTimeout(this.appendHandle);
}
if (!this.isAppendTime) {
this.appendStartTime = null;
return;
}
//首先从本地读取
let duration = studyUtil.getStudyDuration();
//console.log('追加学习时长,当前本地积累的学习时长='+duration);
//追加学习长
let $this = this;
if (this.appendStartTime == null) {
this.appendStartTime = new Date();
this.appendHandle = setTimeout(function() {
$this.appendStudyTime();
}, $this.appentInterval); //设置定时追加学习时长
//保存之前的
if (duration >= 60 ) {
this.saveStudyDuration(duration);
}
return;
}
//如果当前追加开始时间不为空
let now = new Date();
let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数
let sen = Math.round(m / 1000); //计算秒数
// 每次添加的是定时器计时的时间
duration = duration + sen;//追加的是秒
if (duration >= 60) { //一分钟保存一次
this.saveStudyDuration(duration);
} else {
studyUtil.setStudyDuration(duration); //添加到本地存储中
}
//重新覆盖时间
this.appendStartTime = new Date();
//启动下次追加学习时长
this.appendHandle = setTimeout(function() {
$this.appendStudyTime();
}, $this.appentInterval);
this.appendHandle = setTimeout(() => {
let endTime = new Date().getTime();
this.appentInterval = 60;
let duration = Math.round((endTime - this.appendStartTime) / 1000);
this.appendStudyTime();
this.saveStudyDuration(duration);
}, this.appentInterval * 1000);
},
// appendStudyTime() {
// //console.log('开始追加学习时长',this.isAppendTime);
// if (this.studyId == '') {
// return;
// }
// if (!this.curContent.id) {
// return;
// }
// //清除之前的
// if(this.appendHandle != null) {
// window.clearTimeout(this.appendHandle);
// }
// if (!this.isAppendTime) {
// this.appendStartTime = null;
// return;
// }
// //首先从本地读取
// let duration = studyUtil.getStudyDuration();
// //console.log('追加学习时长,当前本地积累的学习时长='+duration);
// //追加学习长
// let $this = this;
// if (this.appendStartTime == null) {
// this.appendStartTime = new Date();
// this.appendHandle = setTimeout(function() {
// $this.appendStudyTime();
// }, $this.appentInterval); //设置定时追加学习时长
// //保存之前的
// if (duration >= 60 ) {
// this.saveStudyDuration(duration);
// }
// return;
// }
// //如果当前追加开始时间不为空
// let now = new Date();
// let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数
// let sen = Math.round(m / 1000); //计算秒数
// // 每次添加的是定时器计时的时间
// duration = duration + sen;//追加的是秒
// if (duration >= 60) { //一分钟保存一次
// this.saveStudyDuration(duration);
// } else {
// studyUtil.setStudyDuration(duration); //添加到本地存储中
// }
// //重新覆盖时间
// this.appendStartTime = new Date();
// //启动下次追加学习时长
// this.appendHandle = setTimeout(function() {
// $this.appendStudyTime();
// }, $this.appentInterval);
// },
appendStudyOtherTime() { //非音视频课学习时长的增加,每一分钟保存一次
//console.log('开始追加学习时长',this.isAppendTime);
if (this.studyId == '') {