summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2014-01-19 11:34:37 -0500
committerAlex Xu <alex_y_xu@yahoo.ca>2014-01-19 11:34:37 -0500
commitafa4dcf0a43848df652c7c0dfcd1da6d5e5bd839 (patch)
tree89fe1ea3298947a719346349cebf17f7dcc99da6 /www
parent8ccc464b0de39e7fc73b3c3e50f80f6c2452c8fe (diff)
downloadhtml5ks-afa4dcf0a43848df652c7c0dfcd1da6d5e5bd839.tar.xz
html5ks-afa4dcf0a43848df652c7c0dfcd1da6d5e5bd839.zip
Stuff.
Diffstat (limited to 'www')
-rw-r--r--www/js/api.js26
-rw-r--r--www/js/imachine.js2
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":