mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -05:00
Merge pull request #35 from paulkaplan/return-promises
Return the loader promise for chaining
This commit is contained in:
commit
f65fa366e0
1 changed files with 5 additions and 3 deletions
|
@ -59,6 +59,10 @@ function AudioEngine () {
|
|||
* Decode a sound, decompressing it into audio samples.
|
||||
* Store a reference to it the sound in the audioBuffers dictionary, indexed by md5
|
||||
* @param {Object} sound - an object containing audio data and metadata for a sound
|
||||
* @property {Buffer} data - sound data loaded from scratch-storage.
|
||||
* @property {string} format - format type, either empty or adpcm.
|
||||
* @property {string} md5 - the MD5 and extension of the sound.
|
||||
* @returns {?Promise} - a promise which will resolve after the audio buffer is stored, or null on error.
|
||||
*/
|
||||
AudioEngine.prototype.decodeSound = function (sound) {
|
||||
|
||||
|
@ -76,8 +80,7 @@ AudioEngine.prototype.decodeSound = function (sound) {
|
|||
}
|
||||
|
||||
var storedContext = this;
|
||||
|
||||
loaderPromise.then(
|
||||
return loaderPromise.then(
|
||||
function (decodedAudio) {
|
||||
storedContext.audioBuffers[sound.md5] = new Tone.Buffer(decodedAudio);
|
||||
},
|
||||
|
@ -319,4 +322,3 @@ AudioPlayer.prototype.setVolume = function (value) {
|
|||
};
|
||||
|
||||
module.exports = AudioEngine;
|
||||
|
||||
|
|
Loading…
Reference in a new issue