Embed: don't trigger more errors when the stream has died
This commit is contained in:
parent
be7e44727f
commit
7a0b425fc4
4 changed files with 46 additions and 25 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -72,6 +72,7 @@ function MistVideo(streamName,options) {
|
|||
start: function(callback,delay){
|
||||
var i = setTimeout(function(){
|
||||
delete MistVideo.timers.list[i];
|
||||
if (MistVideo.destroyed) return;
|
||||
callback();
|
||||
},delay);
|
||||
this.list[i] = new Date(new Date().getTime() + delay);
|
||||
|
@ -1017,7 +1018,9 @@ function MistVideo(streamName,options) {
|
|||
}
|
||||
},
|
||||
report: function(d){
|
||||
if (MistVideo.socket.readyState == 1) {
|
||||
MistVideo.socket.send(JSON.stringify(d));
|
||||
}
|
||||
},
|
||||
reportStats: function(){
|
||||
var d = {};
|
||||
|
@ -1093,22 +1096,22 @@ function MistVideo(streamName,options) {
|
|||
});
|
||||
Object.defineProperty(d,"videoHeight",{
|
||||
get: function(){
|
||||
return MistVideo.video.videoHeight;
|
||||
return MistVideo.video ? MistVideo.video.videoHeight : null;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(d,"videoWidth",{
|
||||
get: function(){
|
||||
return MistVideo.video.videoWidth;
|
||||
return MistVideo.video ? MistVideo.video.videoWidth : null;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(d,"playerHeight",{
|
||||
get: function(){
|
||||
return MistVideo.video.clientHeight;
|
||||
return MistVideo.video ? MistVideo.video.clientHeight : null;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(d,"playerWidth",{
|
||||
get: function(){
|
||||
return MistVideo.video.clientWidth;
|
||||
return MistVideo.video ? MistVideo.video.clientWidth : null;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1354,6 +1357,7 @@ function MistVideo(streamName,options) {
|
|||
}
|
||||
if (this.socket) {
|
||||
if (this.reporting) {
|
||||
this.reporting.reportStats();
|
||||
this.reporting.report({unload:reason ? reason : null});
|
||||
}
|
||||
this.socket.destroy();
|
||||
|
|
|
@ -123,11 +123,11 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
resolve();
|
||||
};
|
||||
player.ms.onsourceclose = function(e){
|
||||
console.error("ms close",e);
|
||||
if (player.debugging) console.error("ms close",e);
|
||||
send({type:"stop"}); //stop sending data please something went wrong
|
||||
};
|
||||
player.ms.onsourceended = function(e){
|
||||
console.error("ms ended",e);
|
||||
if (player.debugging) console.error("ms ended",e);
|
||||
|
||||
//for debugging
|
||||
|
||||
|
@ -282,7 +282,8 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
player.sb.appendBuffer(data);
|
||||
}
|
||||
catch(e){
|
||||
if (e.name == "QuotaExceededError") {
|
||||
switch (e.name) {
|
||||
case "QuotaExceededError": {
|
||||
if (video.buffered.length) {
|
||||
if (video.currentTime - video.buffered.start(0) > 1) {
|
||||
//clear as much from the buffer as we can
|
||||
|
@ -298,6 +299,18 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
player.sb._append(data); //now try again
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "InvalidStateError": {
|
||||
player.api.pause(); //playback is borked, so stop downloading more data
|
||||
if (MistVideo.video.error) {
|
||||
//Failed to execute 'appendBuffer' on 'SourceBuffer': The HTMLMediaElement.error attribute is not null
|
||||
|
||||
//the video element error is already triggering the showError()
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
MistVideo.showError(e.message);
|
||||
}
|
||||
|
@ -371,7 +384,7 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
};
|
||||
this.ws.onclose = function(e){
|
||||
MistVideo.log("MP4 over WS: websocket closed");
|
||||
if (this.wasConnected && (!MistVideo.destroyed) && (MistVideo.state == "Stream is online")) {
|
||||
if (this.wasConnected && (!MistVideo.destroyed) && (MistVideo.state == "Stream is online") && (!MistVideo.video.error)) {
|
||||
MistVideo.log("MP4 over WS: reopening websocket");
|
||||
player.wsconnect().then(function(){
|
||||
if (!player.sb) {
|
||||
|
@ -680,9 +693,13 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
}
|
||||
var data = new Uint8Array(e.data);
|
||||
if (data) {
|
||||
//if (new Date().getTime() - MistVideo.bootMs > 15e3) { data.fill(0,0,Math.floor(data.length*0.1)); } //corrupt the data pl0x :D
|
||||
|
||||
if (player.monitor && player.monitor.bitCounter) {
|
||||
for (var i in player.monitor.bitCounter) {
|
||||
player.monitor.bitCounter[i] += e.data.byteLength*8;
|
||||
}
|
||||
}
|
||||
if ((player.sb) && (!player.msgqueue)) {
|
||||
if (player.sb.updating || player.sb.queue.length || player.sb._busy) {
|
||||
player.sb.queue.push(data);
|
||||
|
|
Loading…
Add table
Reference in a new issue