X-Git-Url: https://git.yukkurigames.com/?p=pwl6.git;a=blobdiff_plain;f=src%2Fyuu%2Faudio.js;h=6b971a1edb66ceb6c58a4f520206c3b1e7f9ff79;hp=0e543a7154e7f21ce057cefb9e22086cd429fcb9;hb=77894cae974e5d2912a0451cac6c603f8656681f;hpb=f96f0ecc5cd905dba4d20f3a06d154bf2683bff3 diff --git a/src/yuu/audio.js b/src/yuu/audio.js index 0e543a7..6b971a1 100644 --- a/src/yuu/audio.js +++ b/src/yuu/audio.js @@ -89,7 +89,7 @@ currentTime: { alias: "_ctx.currentTime" }, - decodeAudioData: function (data) { + decodeAudioData: function (data, hint) { var ctx = this._ctx; try { return ctx.decodeAudioData(data); @@ -97,8 +97,10 @@ return new Promise(function (resolve, reject) { ctx.decodeAudioData(data, function (buffer) { resolve(buffer); - }, function () { - reject(new Error("Error decoding audio buffer")); + }, function (err) { + reject(new Error("Error decoding audio buffer" + + (hint ? ": " + hint : "") + + ": " + err.toString())); }); }); } @@ -174,7 +176,9 @@ 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)); }