X-Git-Url: https://git.yukkurigames.com/?p=pwl6.git;a=blobdiff_plain;f=src%2Fyuu%2Faudio.js;h=6b971a1edb66ceb6c58a4f520206c3b1e7f9ff79;hp=d127fb8d518496bc11ca877d01c2af8259959204;hb=77894cae974e5d2912a0451cac6c603f8656681f;hpb=9f0bd6f08de07960e2c47a0d4b65b416c68c3f8a diff --git a/src/yuu/audio.js b/src/yuu/audio.js index d127fb8..6b971a1 100644 --- a/src/yuu/audio.js +++ b/src/yuu/audio.js @@ -29,7 +29,6 @@ this._masterVolume.gain.value = 0.5; this._musicVolume.gain.value = 0.5; - this._bufferCache = {}; this._mute = false; this._storage = null; this._volume = this._masterVolume.gain.value; @@ -90,7 +89,7 @@ currentTime: { alias: "_ctx.currentTime" }, - decodeAudioData: function (data) { + decodeAudioData: function (data, hint) { var ctx = this._ctx; try { return ctx.decodeAudioData(data); @@ -98,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())); }); }); } @@ -175,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)); }