Include URL in audio load error message.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Mon, 13 Jul 2015 22:39:28 +0000 (00:39 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Mon, 13 Jul 2015 22:39:28 +0000 (00:39 +0200)
src/yuu/audio.js

index 0e543a7154e7f21ce057cefb9e22086cd429fcb9..cc00cf7424ada80841e8b8b32f160090804d6c56 100644 (file)
@@ -89,7 +89,7 @@
 
         currentTime: { alias: "_ctx.currentTime" },
 
-        decodeAudioData: function (data) {
+        decodeAudioData: function (data, hint) {
             var ctx = this._ctx;
             try {
                 return ctx.decodeAudioData(data);
@@ -98,7 +98,8 @@
                     ctx.decodeAudioData(data, function (buffer) {
                         resolve(buffer);
                     }, function () {
-                        reject(new Error("Error decoding audio buffer"));
+                        reject(new Error("Error decoding audio buffer"
+                                         + (hint ? ": " + hint : "")));
                     });
                 });
             }
             var url = yuu.resourcePath(path, "sound", "wav");
             this.data = null;
             this.ready = yuu.GET(url, { responseType: "arraybuffer" })
-                .then(ctx.decodeAudioData.bind(ctx))
+                .then(function (data) {
+                    return ctx.decodeAudioData(data, url);
+                })
                 .then(yf.setter.bind(this, "buffer"))
                 .then(yf.K(this));
         }