From 481d21ff70a6bfd77dde5d4835d7d0ab01c01850 Mon Sep 17 00:00:00 2001 From: drigato <denise.rigato@sourcefabric.org> Date: Tue, 7 Apr 2015 11:34:21 -0400 Subject: [PATCH] SAAS-662: Make player auto-connect if there is a problem with the stream HTML5 error handling --- .../scripts/embeddableplayer/embed-code.phtml | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml b/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml index 4ab35b768..66117609a 100644 --- a/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml +++ b/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml @@ -15,7 +15,7 @@ 'volume': 100, 'jsevents': true, 'autoplay': false, - 'buffering': 5, + 'buffering': 0, 'title': 'test', 'bgcolor': '#FFFFFF', 'skin': 'mcclean', @@ -26,27 +26,37 @@ if (this.playerMode == "manual") { this.settings.url = "<?php echo $this->streamURL ?>"; this.settings.codec = "<?php echo $this->codec ?>"; - MRP.insert(this.settings); } else if (this.playerMode == "auto") { this.availableMobileStreamQueue = <?php echo $this->availableMobileStreams?>; this.availableDesktopStreamQueue = <?php echo $this->availableDesktopStreams?>; var stream = this.getNextAvailableStream(); this.settings.url = stream["url"]; this.settings.codec = stream["codec"]; - MRP.insert(this.settings); } + MRP.insert(this.settings); + $("p.station_name").html("<?php echo $this->station_name?>"); getMetadata(); - // detects errors in HTML5 mode + // detects events in HTML5 mode if (!this.flashDetect) { + MRP.html.audio.addEventListener('error', function failed(e) { + console.log("HTML error"); var stream = musesPlayer.getNextAvailableStream(); - console.log(stream); - MRP.html.audio.src = stream["url"]; - MRP.html.audio.play(); + var audio = $(MRP.html.audio); + audio.src = stream["url"]; + 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); } }; @@ -109,6 +119,7 @@ }; MusesPlayer.prototype.setURL = function(url) { + console.log("setURL"); MRP.setUrl(url); };