Embed: improved handling of state changes, added options to hide error title
This commit is contained in:
parent
214b584956
commit
a75ac5713c
5 changed files with 31 additions and 37 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -291,7 +291,7 @@ function MistVideo(streamName,options) {
|
||||||
MistVideo.log(e);
|
MistVideo.log(e);
|
||||||
e = d.on_error;
|
e = d.on_error;
|
||||||
}
|
}
|
||||||
MistVideo.showError(e,{reload:true});
|
MistVideo.showError(e,{reload:true,hideTitle:true});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +601,15 @@ function MistVideo(streamName,options) {
|
||||||
msg = "An error was encountered.";
|
msg = "An error was encountered.";
|
||||||
//console.log("Err:",e);
|
//console.log("Err:",e);
|
||||||
}
|
}
|
||||||
|
if (MistVideo.state == "Stream is online") {
|
||||||
MistVideo.showError(msg);
|
MistVideo.showError(msg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//it was probaby an error like "PIPELINE_ERROR_READ: FFmpegDemuxer: data source error" because the live stream has ended. Print it in the log, but display the stream state instead.
|
||||||
|
MistVideo.log(msg,"error");
|
||||||
|
MistVideo.showError(MistVideo.state,{polling:true});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//add general resize function
|
//add general resize function
|
||||||
|
@ -892,7 +900,7 @@ function MistVideo(streamName,options) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("WebSocket" in window) {
|
if (false) {
|
||||||
function openSocket() {
|
function openSocket() {
|
||||||
MistVideo.log("Opening stream status stream..");
|
MistVideo.log("Opening stream status stream..");
|
||||||
var url = MistVideo.options.host.replace(/^http/i,"ws");
|
var url = MistVideo.options.host.replace(/^http/i,"ws");
|
||||||
|
@ -920,6 +928,8 @@ function MistVideo(streamName,options) {
|
||||||
openWithGet();
|
openWithGet();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
var on_ended_show_state = false;
|
||||||
|
var on_waiting_show_state = false;
|
||||||
socket.addEventListener("message",function(e){
|
socket.addEventListener("message",function(e){
|
||||||
var data = JSON.parse(e.data);
|
var data = JSON.parse(e.data);
|
||||||
if (!data) { MistVideo.showError("Error while parsing stream status stream. Obtained: "+e.data.toString(),{reload:true}); }
|
if (!data) { MistVideo.showError("Error while parsing stream status stream. Obtained: "+e.data.toString(),{reload:true}); }
|
||||||
|
@ -944,6 +954,19 @@ function MistVideo(streamName,options) {
|
||||||
if ((MistVideo.player) && (MistVideo.player.api) && (!MistVideo.player.api.paused)) {
|
if ((MistVideo.player) && (MistVideo.player.api) && (!MistVideo.player.api.paused)) {
|
||||||
//something is (still) playing
|
//something is (still) playing
|
||||||
MistVideo.log(data.error,"error");
|
MistVideo.log(data.error,"error");
|
||||||
|
|
||||||
|
//on ended, show state
|
||||||
|
if (!on_ended_show_state) {
|
||||||
|
on_ended_show_state = MistUtil.event.addListener(MistVideo.video,"ended",function(){
|
||||||
|
MistVideo.showError(data.error,{polling:true});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!on_waiting_show_state) {
|
||||||
|
on_ended_show_state = MistUtil.event.addListener(MistVideo.video,"waiting",function(){
|
||||||
|
MistVideo.showError(data.error,{polling:true});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buttons = {polling:true};
|
buttons = {polling:true};
|
||||||
|
@ -959,6 +982,8 @@ function MistVideo(streamName,options) {
|
||||||
//console.log("stream status stream said",data);
|
//console.log("stream status stream said",data);
|
||||||
MistVideo.state = "Stream is online";
|
MistVideo.state = "Stream is online";
|
||||||
MistVideo.clearError();
|
MistVideo.clearError();
|
||||||
|
if (on_ended_show_state) { MistUtil.event.removeListener(on_ended_show_state); }
|
||||||
|
if (on_waiting_show_state) { MistUtil.event.removeListener(on_waiting_show_state); }
|
||||||
|
|
||||||
if (!MistVideo.info) {
|
if (!MistVideo.info) {
|
||||||
onStreamInfo(data);
|
onStreamInfo(data);
|
||||||
|
|
|
@ -1704,7 +1704,7 @@ MistSkins["default"] = {
|
||||||
message_container.className = "message";
|
message_container.className = "message";
|
||||||
this.appendChild(message_container);
|
this.appendChild(message_container);
|
||||||
|
|
||||||
if (!options.polling && !options.passive) {
|
if (!options.polling && !options.passive && !options.hideTitle) {
|
||||||
var header = document.createElement("h3");
|
var header = document.createElement("h3");
|
||||||
message_container.appendChild(header);
|
message_container.appendChild(header);
|
||||||
header.appendChild(document.createTextNode("The player has encountered a problem"));
|
header.appendChild(document.createTextNode("The player has encountered a problem"));
|
||||||
|
|
|
@ -109,37 +109,6 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//special HLS live when-stream-ends code because holy crap latency
|
|
||||||
MistUtil.event.addListener(MistVideo.options.target,"error",function(e){
|
|
||||||
var eventdata = false;
|
|
||||||
switch (e.message) {
|
|
||||||
case "Stream is shutting down": {
|
|
||||||
//MistVideo.clearError(); //we've probably got loads of buffer left to play
|
|
||||||
e.preventDefault();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Stream is offline": {
|
|
||||||
MistVideo.clearError(); //we've probably got loads of buffer left to play
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (MistVideo.video) {
|
|
||||||
eventdata = MistUtil.event.addListener(MistVideo.video,"ended",function(){
|
|
||||||
//show stream offline error
|
|
||||||
MistVideo.showError("Stream is offline ",{polling:true});
|
|
||||||
|
|
||||||
if (eventdata) { MistUtil.event.removeListener(eventdata); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Stream is waiting for data": {
|
|
||||||
if (eventdata) { MistUtil.event.removeListener(eventdata); }
|
|
||||||
me.api.pause();
|
|
||||||
MistVideo.reload();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},MistVideo.video);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
MistVideo.log("Built html");
|
MistVideo.log("Built html");
|
||||||
|
|
Loading…
Add table
Reference in a new issue