mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-16 14:26:43 +08:00
视频禁用拖动修改
This commit is contained in:
@@ -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<newCurrentTime){
|
||||
|
||||
var arr = time&&JSON.parse(time) || {}
|
||||
console.log('arr[this.blobId]::22',arr[this.blobId],this.currentProgress)
|
||||
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))
|
||||
}
|
||||
|
||||
if(time && arr[this.blobId]* this.videoDom.duration < this.newCurrentTime){
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -464,11 +480,15 @@ export default {
|
||||
/* 点击进度条更新视频播放进度
|
||||
*/
|
||||
updateProgressByClickBar(value) {
|
||||
let duration = this.videoDom.duration;
|
||||
this.currentProgress = value;
|
||||
let new_current_time = Math.round(value * duration);
|
||||
this.barrageTimelineStart = new_current_time;
|
||||
this.videoDom.currentTime = new_current_time;
|
||||
if(this.videoDom){
|
||||
|
||||
let duration = this.videoDom.duration;
|
||||
this.currentProgress = value;
|
||||
let new_current_time = Math.round(value * duration);
|
||||
this.barrageTimelineStart = new_current_time;
|
||||
this.videoDom.currentTime = new_current_time;
|
||||
console.log('value 222::',value,duration,new_current_time)
|
||||
}
|
||||
},
|
||||
/* 通过新的播放时间更新视频播放进度
|
||||
*/
|
||||
@@ -582,8 +602,10 @@ export default {
|
||||
this.videoDom.play();
|
||||
},
|
||||
onAudioTimeUpdate() {
|
||||
const currentTime = this.$refs.video.currentTime;
|
||||
this.$emit('onTimeUpdate', currentTime);
|
||||
if(this.$refs.video){
|
||||
const currentTime = this.$refs.video.currentTime;
|
||||
this.$emit('onTimeUpdate', currentTime);
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
Reference in New Issue
Block a user