From c5cf6d9b40d1da4fd506ecd7c5247a1f20daa5c2 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Thu, 4 May 2017 12:29:10 -0400 Subject: [PATCH] Use asset id reference on sounds --- src/import/load-sound.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/import/load-sound.js b/src/import/load-sound.js index f54f5fe32..a308e1516 100644 --- a/src/import/load-sound.js +++ b/src/import/load-sound.js @@ -19,10 +19,17 @@ const loadSound = function (sound, runtime) { } const idParts = sound.md5.split('.'); const md5 = idParts[0]; - return runtime.storage.load(runtime.storage.AssetType.Sound, md5).then(soundAsset => { - sound.data = soundAsset.data; - return runtime.audioEngine.decodeSound(sound).then(() => sound); - }); + return runtime.storage.load(runtime.storage.AssetType.Sound, md5) + .then(soundAsset => { + 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;