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