diff options
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/api.js | 26 | ||||
-rw-r--r-- | www/js/imachine.js | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/www/js/api.js b/www/js/api.js index 833b120..84cc881 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -61,13 +61,20 @@ window.html5ks.api = new (function () { for (; i < types.length; i++) { if (Modernizr.audio[types[i]]) { audio.src = src + "." + types[i]; + audio.load(); + audio.volume = fade ? 0 : volume; return i; } } + return null; }; - var i = setNextType(0); + var i; + audio.addEventListener("canplaythrough", function canplaythrough() { + audio.removeEventListener("canplaythrough", canplaythrough, false); + audio.play(); + }); audio.addEventListener("playing", function playing() { audio.removeEventListener("playing", playing, false); if (fade) { @@ -77,19 +84,20 @@ window.html5ks.api = new (function () { }, false); audio.onerror = function (e) { if (e.code === e.MEDIA_ERR_SRC_NOT_SUPPORTED) { - i = setNextType(i); - if (i) { + i = setNextType(++i); + if (!i) { + console.error("No media formats appear to be supported."); + console.error(e); deferred.resolve(); - } else { - throw new Error(e); } } else { - throw new Error(e); + console.error(e); + deferred.resolve(); } }; - audio.load(); - audio.volume = fade ? 0 : volume; - audio.play(); + + i = setNextType(0); + return deferred.promise; }, diff --git a/www/js/imachine.js b/www/js/imachine.js index 7a1f7de..968df84 100644 --- a/www/js/imachine.js +++ b/www/js/imachine.js @@ -56,7 +56,7 @@ html5ks.imachine = new (function () { var cpy = inst.slice(0), type = '', next = null; - el: while (type = cpy.shift()) { + el: while ((type = cpy.shift())) { switch (type) { case "if": case "elif": |