Use asset id reference on sounds

This commit is contained in:
Ray Schamp 2017-05-04 12:29:10 -04:00
parent 4f59e98bc8
commit c5cf6d9b40

View file

@ -19,10 +19,17 @@ const loadSound = function (sound, runtime) {
} }
const idParts = sound.md5.split('.'); const idParts = sound.md5.split('.');
const md5 = idParts[0]; const md5 = idParts[0];
return runtime.storage.load(runtime.storage.AssetType.Sound, md5).then(soundAsset => { return runtime.storage.load(runtime.storage.AssetType.Sound, md5)
sound.data = soundAsset.data; .then(soundAsset => {
return runtime.audioEngine.decodeSound(sound).then(() => sound); sound.assetId = soundAsset.assetId;
}); sound.assetType = runtime.storage.AssetType.Sound;
return runtime.audioEngine.decodeSound(Object.assign(
{},
sound,
{data: soundAsset.data}
));
})
.then(() => sound);
}; };
module.exports = loadSound; module.exports = loadSound;