SAAS-662: Make player auto-connect if there is a problem with the stream

HTML5 error handling
This commit is contained in:
drigato 2015-04-07 11:34:21 -04:00
parent faee0fba98
commit 481d21ff70
1 changed files with 18 additions and 7 deletions

View File

@ -15,7 +15,7 @@
'volume': 100, 'volume': 100,
'jsevents': true, 'jsevents': true,
'autoplay': false, 'autoplay': false,
'buffering': 5, 'buffering': 0,
'title': 'test', 'title': 'test',
'bgcolor': '#FFFFFF', 'bgcolor': '#FFFFFF',
'skin': 'mcclean', 'skin': 'mcclean',
@ -26,27 +26,37 @@
if (this.playerMode == "manual") { if (this.playerMode == "manual") {
this.settings.url = "<?php echo $this->streamURL ?>"; this.settings.url = "<?php echo $this->streamURL ?>";
this.settings.codec = "<?php echo $this->codec ?>"; this.settings.codec = "<?php echo $this->codec ?>";
MRP.insert(this.settings);
} else if (this.playerMode == "auto") { } else if (this.playerMode == "auto") {
this.availableMobileStreamQueue = <?php echo $this->availableMobileStreams?>; this.availableMobileStreamQueue = <?php echo $this->availableMobileStreams?>;
this.availableDesktopStreamQueue = <?php echo $this->availableDesktopStreams?>; this.availableDesktopStreamQueue = <?php echo $this->availableDesktopStreams?>;
var stream = this.getNextAvailableStream(); var stream = this.getNextAvailableStream();
this.settings.url = stream["url"]; this.settings.url = stream["url"];
this.settings.codec = stream["codec"]; this.settings.codec = stream["codec"];
MRP.insert(this.settings);
} }
MRP.insert(this.settings);
$("p.station_name").html("<?php echo $this->station_name?>"); $("p.station_name").html("<?php echo $this->station_name?>");
getMetadata(); getMetadata();
// detects errors in HTML5 mode // detects events in HTML5 mode
if (!this.flashDetect) { if (!this.flashDetect) {
MRP.html.audio.addEventListener('error', function failed(e) { MRP.html.audio.addEventListener('error', function failed(e) {
console.log("HTML error");
var stream = musesPlayer.getNextAvailableStream(); var stream = musesPlayer.getNextAvailableStream();
console.log(stream); var audio = $(MRP.html.audio);
MRP.html.audio.src = stream["url"]; audio.src = stream["url"];
MRP.html.audio.play(); audio[0].load();
audio[0].play();
}, true);
MRP.html.audio.addEventListener('pause', function paused(e) {
//this is when pause happens
console.log("HTML paused");
//src = MRP.html.audio.src;
//MRP.html.audio.src = "";
}, true); }, true);
} }
}; };
@ -109,6 +119,7 @@
}; };
MusesPlayer.prototype.setURL = function(url) { MusesPlayer.prototype.setURL = function(url) {
console.log("setURL");
MRP.setUrl(url); MRP.setUrl(url);
}; };