diff --git a/web/app/assets/javascripts/jquery.listenbroadcast.js b/web/app/assets/javascripts/jquery.listenbroadcast.js index 73837da8f..00f87fcbe 100644 --- a/web/app/assets/javascripts/jquery.listenbroadcast.js +++ b/web/app/assets/javascripts/jquery.listenbroadcast.js @@ -92,32 +92,38 @@ .done(function(response) { if(!sessionInfo.mount) { - transition(PlayStateSessionOver); - destroy(); + if (sessionInfo.session_removed_at) { + transition(PlayStateSessionOver); + destroy(); + } } else { - recreateAudioElement(); + try { + recreateAudioElement(); - audioDomElement.load(); + audioDomElement.load(); - retryAttempts = 0; + retryAttempts = 0; - transition(PlayStateInitializing); + transition(PlayStateInitializing); - // keep this after transition, because any transition clears this timer - waitForBufferingTimeout = setTimeout(noBuffer, WAIT_FOR_BUFFER_TIMEOUT); - logger.debug("setting buffering timeout"); - rest.addPlayablePlay(musicSessionId, 'JamRuby::MusicSession', null, context.JK.currentUserId); + // keep this after transition, because any transition clears this timer + waitForBufferingTimeout = setTimeout(noBuffer, WAIT_FOR_BUFFER_TIMEOUT); + logger.debug("setting buffering timeout"); + rest.addPlayablePlay(musicSessionId, 'JamRuby::MusicSession', null, context.JK.currentUserId); - if(needsCanPlayGuard()) { - $audio.bind('canplay', function() { + if(needsCanPlayGuard()) { + $audio.bind('canplay', function() { + audioDomElement.play(); + }) + } + else { audioDomElement.play(); - }) + } } - else { - audioDomElement.play(); + catch (err) { + console.log("Catching error = %o", err); } - } }) } @@ -137,7 +143,12 @@ transition(PlayStateNone); - recreateAudioElement(); + try { + recreateAudioElement(); + } + catch (err) { + console.log("Catching error = %o", err); + } } function destroy() { @@ -145,7 +156,12 @@ //$audio.remove(); //$audio = null; //audioDomElement = null; - recreateAudioElement() + try { + recreateAudioElement(); + } + catch (err) { + console.log("Catching error = %o", err); + } // destroyed = true; //} } @@ -249,31 +265,37 @@ .done(function(response) { if(!sessionInfo.mount) { - transition(PlayStateSessionOver); - destroy(); + if (sessionInfo.session_removed_at) { + transition(PlayStateSessionOver); + destroy(); + } } else { // tell audio to stop/start, in attempt to retry //audioDomElement.pause(); - recreateAudioElement(); + try { + recreateAudioElement(); - audioDomElement.load(); - if(needsCanPlayGuard()) { - $audio.bind('canplay', function() { + audioDomElement.load(); + if(needsCanPlayGuard()) { + $audio.bind('canplay', function() { + audioDomElement.play(); + }) + } + else { audioDomElement.play(); - }) - } - else { - audioDomElement.play(); - } + } - transition(PlayStateRetrying); + transition(PlayStateRetrying); - waitForBufferingTimeout = setTimeout(noBuffer, WAIT_FOR_BUFFER_TIMEOUT); + waitForBufferingTimeout = setTimeout(noBuffer, WAIT_FOR_BUFFER_TIMEOUT); + } + catch (err) { + console.log("Catching error = %o", err); + } } - }) - + }); } } @@ -483,9 +505,11 @@ checkServer() .done(function(response) { if(!sessionInfo.mount) { - transition(PlayStateSessionOver); - destroy(); - }}) + if (sessionInfo.session_removed_at) { + transition(PlayStateSessionOver); + destroy(); + } + }}); } } @@ -694,10 +718,12 @@ else { mountInfo = null; - transition(PlayStateSessionOver); - destroy(); + if (sessionInfo.session_removed_at) { + transition(PlayStateSessionOver); + destroy(); + } - context.JK.app.layout.notify('This session can not currently broadcast') + context.JK.app.notify({"title": "Unable to Broadcast Session", "text": "This session cannot be broadcasted. The session organizer may have configured it to be private."}); } }) .fail(function() {