From 15a8e3fa1f5e8fb2accfa58d63e6cfd814ced198 Mon Sep 17 00:00:00 2001 From: drigato Date: Tue, 31 Mar 2015 17:20:42 -0400 Subject: [PATCH] Moved html5 error listener to MusesPlayer constructor --- .../scripts/embeddableplayer/embed-code.phtml | 17 ++++++++++------- 1 file changed, 10 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 5c1a57b74..076b6c38f 100644 --- a/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml +++ b/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml @@ -39,6 +39,16 @@ $("p.station_name").html("station_name?>"); getMetadata(); + + // detects errors in HTML5 mode + if (!this.flashDetect) { + MRP.html.audio.addEventListener('error', function failed(e) { + var stream = musesPlayer.getNextAvailableStream(); + console.log(stream); + MRP.html.audio.src = stream["url"]; + MRP.html.audio.play(); + }, true); + } }; MusesPlayer.prototype.mobileDetect = function() { @@ -120,13 +130,6 @@ MRP.html.audio.src = MRP.html.src; MRP.html.audio.play(); - - // detects errors in HTML5 mode - MRP.html.audio.addEventListener('error', function failed(e) { - var stream = musesPlayer.getNextAvailableStream(); - MRP.html.audio.src = stream["url"]; - MRP.html.audio.play(); - }, true); } function musesHTMLStopClick() {