* supporting session widget in rich client

This commit is contained in:
Seth Call 2014-03-04 12:22:42 -06:00
parent 3afdd55a15
commit 314d3c9dac
1 changed files with 30 additions and 5 deletions

View File

@ -192,7 +192,7 @@
// tell audio to stop/start, in attempt to retry
//audioDomElement.pause();
audioDomElement.load();
if(isDesktopSafari()) {
if(needsCanPlayGuard()) {
$audio.bind('canplay', function() {
audioDomElement.play();
})
@ -212,7 +212,7 @@
function isNoisyEvent(eventName) {
if(playState == PlayStateNone) {
console.log("ignoring: " + eventName)
logger.log("ignoring: " + eventName)
return true;
}
@ -234,6 +234,11 @@
if(isNoisyEvent('pause')) return;
logger.log("pause", arguments);
if(treatPauseLikeEnd()) {
transition(PlayStateEnded);
return;
};
transition(PlayStateStalled);
}
@ -274,6 +279,8 @@
logger.log("ignoring stalled msg for non-active audio element")
return;
}
if(ignoreStalls()) return;
// fires in Chrome on page load
if(playState == PlayStateBuffering || playState == PlayStatePlaying) {
@ -287,6 +294,8 @@
// fires in FF on page load
if(ignoreSuspend()) return;
transition(PlayStateStalled);
}
@ -394,18 +403,34 @@
}
}
function treatPauseLikeEnd() {
// never see a pause event until the session is over, in the rich client
return playState == PlayStatePlaying && navigator.userAgent.toLowerCase().indexOf('jamkazam') > -1;
}
function ignoreSuspend() {
// client always does a 'suspend' after playing. bleh
return playState == PlayStatePlaying && navigator.userAgent.toLowerCase().indexOf('jamkazam') > -1;
}
function isDesktopSafari() {
function ignoreStalls() {
return false;
}
function needsCanPlayGuard() {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari') != -1) {
if (ua.indexOf('chrome') > -1) {
} else {
if (ua.match(/iPad/i) || ua.match(/iPhone/i)) {
return true; // not sure yet which way this should go
if (ua.indexOf('ipad') > -1 || ua.indexOf('iphone') > -1) {
return false; // not sure yet which way this should go
}
return true;
}
}
else if(ua.indexOf('jamkazam') > -1) {
return true;
}
return false;
}