mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Use asset id reference on sounds
This commit is contained in:
parent
4f59e98bc8
commit
c5cf6d9b40
1 changed files with 11 additions and 4 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue