console.log("Starting stream Check");
if (is\\_ie9) {
console.log ("Using XDR because IE9 is stupid");
streamcheckXDR();
setInterval(function(){streamcheckXDR()},10000);
}
else {
streamcheck();
setInterval(function(){streamcheck()},10000);
}
function streamcheckXDR() {
console.log("Starting XDR");
xdr = new XDomainRequest();
if(xdr) {
xdr.onerror = function(){ console.log("XDR Error"); };
xdr.onload = function(){ startPlayer(xdr.responseText,"XDR"); };
url = "http://"+streamer+":8086/streamcheck?stream="+stream;
xdr.open("get",url);
xdr.send();
} else {
console.log("Failed to create XDR object");
}
}
function startPlayer(result,mode){
// for some inexplicable reason, running "Boolean" on the XDR output doesn't work
// so we have to call the function and tell it if we're dealing with XDR data or AJAX data.
if(mode == "XDR") {
if (result === "true") { curstatus = true;}
if (result === "false") { curstatus = false;}
} else {
curstatus = Boolean(result);
}
//console.log("Result: "+result);
//console.log("Previous: "+prevstatus);
//console.log("Current: "+curstatus);
if (curstatus == prevstatus) {
//console.log("No Change");
} else {
if (curstatus) {
if (is\\_iphone || is\\_ipad || is\\_ipod) { iOSPlayer("videoframe",plwd,plht,server,stream);}
else if (is\\_blackberry) { rtspPlayer("videoframe",plwd,plht,server,stream+'\\_+240p');}
else { flashPlayer("videoframe",plwd,plht,server,stream); }
console.log("Changed from false to true");
} else {
var vframe=document.getElementById("videoframe")
if (is\\_iphone || is\\_ipad || is\\_ipod || is\\_blackberry) {
} else {
jwplayer("videoframe").remove();
}
vframe.innerHTML = '';
console.log("Changed from true to false");
}
}
prevstatus = curstatus;
}
function streamcheck() {
console.log("Starting AJAX");
$.ajax({
dataType: "json",
contentType: "text/plain",
type: "GET",
url: "http://"+streamer+":8086/streamcheck?stream="+stream,
error: function(XMLHttpRequest, textStatus, errorThrown)
{
console.log('AJAX Failure:'+ textStatus+':'+errorThrown);
//some stuff on failure
},
success: function(result){startPlayer(result)}
});
}