|
@@ -30,6 +30,7 @@
|
|
tickNum: 0,
|
|
tickNum: 0,
|
|
prevTime:0,
|
|
prevTime:0,
|
|
isReady:false,
|
|
isReady:false,
|
|
|
|
+ onblurTime: 0,
|
|
onPlay: false
|
|
onPlay: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -44,24 +45,7 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- props: {
|
|
|
|
- media:{
|
|
|
|
- type: Object,
|
|
|
|
- default: ()=>{
|
|
|
|
- return {id: '', percent:0}
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- dialog:{
|
|
|
|
- type: Boolean,
|
|
|
|
- default: true
|
|
|
|
- },
|
|
|
|
- options: {
|
|
|
|
- type: Object,
|
|
|
|
- default: () => {
|
|
|
|
- return {}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ props: ['media', 'dialog', 'options'],
|
|
beforeDestroy() {
|
|
beforeDestroy() {
|
|
if (this.timer) {
|
|
if (this.timer) {
|
|
clearInterval(this.timer); //关闭
|
|
clearInterval(this.timer); //关闭
|
|
@@ -74,7 +58,7 @@
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
this.timer = setInterval(this.tick, 5 * 1000);
|
|
this.timer = setInterval(this.tick, 5 * 1000);
|
|
- // this.startMonitor();
|
|
|
|
|
|
+ this.startMonitor();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
playerReadied(player) {
|
|
playerReadied(player) {
|
|
@@ -123,6 +107,7 @@
|
|
this.onPlay = false
|
|
this.onPlay = false
|
|
},
|
|
},
|
|
doPlay(){
|
|
doPlay(){
|
|
|
|
+ this.updateBlurtime()
|
|
if( !this.$refs.videoPlayer || !this.$refs.videoPlayer.player ) return;
|
|
if( !this.$refs.videoPlayer || !this.$refs.videoPlayer.player ) return;
|
|
if( !this.dialog ) return this.doPause();
|
|
if( !this.dialog ) return this.doPause();
|
|
let myPlayer = this.$refs.videoPlayer.player;
|
|
let myPlayer = this.$refs.videoPlayer.player;
|
|
@@ -133,13 +118,18 @@
|
|
onPlayerStart() {
|
|
onPlayerStart() {
|
|
this.onPlay = true
|
|
this.onPlay = true
|
|
},
|
|
},
|
|
|
|
+ updateBlurtime(){
|
|
|
|
+ this.onblurTime = Date.now() + 15*60 * 1000
|
|
|
|
+ },
|
|
startMonitor() {
|
|
startMonitor() {
|
|
let that = this
|
|
let that = this
|
|
window.onblur = function() {
|
|
window.onblur = function() {
|
|
- that.doPause()
|
|
|
|
|
|
+ that.updateBlurtime()
|
|
|
|
+ // that.doPause()
|
|
}
|
|
}
|
|
window.onfocus = function () {
|
|
window.onfocus = function () {
|
|
- that.doPlay()
|
|
|
|
|
|
+ that.updateBlurtime()
|
|
|
|
+ // that.doPlay()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
tickWait(){
|
|
tickWait(){
|
|
@@ -164,9 +154,15 @@
|
|
tick( force = false) {
|
|
tick( force = false) {
|
|
let media = this.media;
|
|
let media = this.media;
|
|
this.tickNum ++
|
|
this.tickNum ++
|
|
|
|
+ console.log("tick", this.onblurTime )
|
|
|
|
+ if( this.onblurTime < Date.now() ){
|
|
|
|
+ this.tickWait();
|
|
|
|
+ return
|
|
|
|
+ }
|
|
// 已经完成
|
|
// 已经完成
|
|
if( this.media.isFinish ) return;
|
|
if( this.media.isFinish ) return;
|
|
|
|
|
|
|
|
+
|
|
// 主动暂停
|
|
// 主动暂停
|
|
let myPlayer = this.$refs.videoPlayer.player;
|
|
let myPlayer = this.$refs.videoPlayer.player;
|
|
let curTimes = parseInt(myPlayer.currentTime());
|
|
let curTimes = parseInt(myPlayer.currentTime());
|