Embed: mews: remove pause when tabbing out as doing so no longer seems to crash the browser
This commit is contained in:
parent
8cd51e5e7d
commit
3cf0070121
2 changed files with 16 additions and 31 deletions
File diff suppressed because one or more lines are too long
|
@ -768,7 +768,7 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
},
|
||||
pause: function(){
|
||||
video.pause();
|
||||
send({type: "hold",});
|
||||
send({type: "hold"});
|
||||
if (player.sb) { player.sb.paused = true; }
|
||||
},
|
||||
setTracks: function(obj){
|
||||
|
@ -791,9 +791,7 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
//it's okay if it fails
|
||||
} catch (e) { }
|
||||
});
|
||||
player.ws.close();
|
||||
delete window.mistMewsOnVisibilityChange;
|
||||
document.removeEventListener("visibilitychange",onVisibilityChange);
|
||||
player.ws.close();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -881,32 +879,6 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
});
|
||||
}
|
||||
});
|
||||
//pause if tab is hidden to prevent buildup of frames
|
||||
var autopaused = false;
|
||||
//only add this once!
|
||||
function onVisibilityChange() {
|
||||
if (document.hidden) {
|
||||
//check if we are playing (not video.paused! that already returns true)
|
||||
if (!player.sb.paused) {
|
||||
player.api.pause();
|
||||
autopaused = true;
|
||||
if (MistVideo.info.type == "live") {
|
||||
autopaused = "live"; //go to live point
|
||||
//NB: even if the player wasn't near the live point when it was paused, we've likely exited the buffer while we were paused, so the current position probably won't exist anymore. Just skip to live.
|
||||
}
|
||||
MistVideo.log("Pausing the player as the tab is inactive.");
|
||||
}
|
||||
}
|
||||
else if (autopaused) {
|
||||
player.api.play(autopaused == "live");
|
||||
autopaused = false;
|
||||
MistVideo.log("Restarting the player as the tab is now active again.");
|
||||
}
|
||||
}
|
||||
if (!window.mistMewsOnVisibilityChange) {
|
||||
window.mistMewsOnVisibilityChange = true;
|
||||
document.addEventListener("visibilitychange",onVisibilityChange);
|
||||
}
|
||||
|
||||
var seeking = false;
|
||||
MistUtil.event.addListener(video,"seeking",function(){
|
||||
|
@ -927,6 +899,19 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
}
|
||||
}
|
||||
});
|
||||
MistUtil.event.addListener(video,"pause",function(){
|
||||
if (player.sb && !player.sb.paused) {
|
||||
MistVideo.log("The browser paused the vid - probably because it has no audio and the tab is no longer visible. Pausing download.");
|
||||
send({type:"hold"});
|
||||
player.sb.paused = true;
|
||||
var p = MistUtil.event.addListener(video,"play",function(){
|
||||
if (player.sb && player.sb.paused) {
|
||||
send({type:"play"});
|
||||
}
|
||||
MistUtil.event.removeListener(p);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (player.debugging) {
|
||||
MistUtil.event.addListener(video,"waiting",function(){
|
||||
|
|
Loading…
Add table
Reference in a new issue