Embed: before giving up, try connecting via http get if websocket fails
This commit is contained in:
parent
23cccb1857
commit
d6ad8f9811
2 changed files with 21 additions and 20 deletions
File diff suppressed because one or more lines are too long
|
@ -875,6 +875,23 @@ function MistVideo(streamName,options) {
|
||||||
|
|
||||||
//listen for changes to the srteam status
|
//listen for changes to the srteam status
|
||||||
//TODO switch to polling-mode if websockets are not supported
|
//TODO switch to polling-mode if websockets are not supported
|
||||||
|
|
||||||
|
function openWithGet() {
|
||||||
|
var url = MistVideo.urlappend(options.host+"/json_"+encodeURIComponent(MistVideo.stream)+".js");
|
||||||
|
MistVideo.log("Requesting stream info from "+url);
|
||||||
|
MistUtil.http.get(url,function(d){
|
||||||
|
if (MistVideo.destroyed) { return; }
|
||||||
|
onStreamInfo(JSON.parse(d));
|
||||||
|
},function(xhr){
|
||||||
|
var msg = "Connection failed: the media server may be offline";
|
||||||
|
MistVideo.showError(msg,{reload:30});
|
||||||
|
if (!MistVideo.info) {
|
||||||
|
MistUtil.event.send("initializeFailed",null,options.target);
|
||||||
|
MistVideo.log("Initialization failed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if ("WebSocket" in window) {
|
if ("WebSocket" in window) {
|
||||||
function openSocket() {
|
function openSocket() {
|
||||||
MistVideo.log("Opening stream status stream..");
|
MistVideo.log("Opening stream status stream..");
|
||||||
|
@ -899,13 +916,9 @@ function MistVideo(streamName,options) {
|
||||||
openSocket();
|
openSocket();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var msg = "Connection failed: the media server may be offline.";
|
|
||||||
MistVideo.showError(msg,{reload:30});
|
|
||||||
|
|
||||||
if (!MistVideo.info) {
|
openWithGet();
|
||||||
MistUtil.event.send("initializeFailed",null,options.target);
|
|
||||||
MistVideo.log("Initialization failed");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
socket.addEventListener("message",function(e){
|
socket.addEventListener("message",function(e){
|
||||||
var data = JSON.parse(e.data);
|
var data = JSON.parse(e.data);
|
||||||
|
@ -1040,19 +1053,7 @@ function MistVideo(streamName,options) {
|
||||||
openSocket();
|
openSocket();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
openWithGet();
|
||||||
//get info
|
|
||||||
var url = this.urlappend(options.host+"/json_"+encodeURIComponent(this.stream)+".js");
|
|
||||||
this.log("Requesting stream info from "+url);
|
|
||||||
MistUtil.http.get(url,function(d){
|
|
||||||
if (MistVideo.destroyed) { return; }
|
|
||||||
onStreamInfo(JSON.parse(d));
|
|
||||||
},function(xhr){
|
|
||||||
var msg = "Connection failed (failed to load "+url+")";
|
|
||||||
MistVideo.showError(msg,{reload:true});
|
|
||||||
MistUtil.event.send("initializeFailed",null,options.target);
|
|
||||||
MistVideo.log("Initialization failed");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unload = function(){
|
this.unload = function(){
|
||||||
|
|
Loading…
Add table
Reference in a new issue