diff --git a/src/containers/record-modal.jsx b/src/containers/record-modal.jsx index ee05f298bbc493332760d6b65a10960c3282734d..45f847807c147f486233c8c7491c4a11a65278f4 100644 --- a/src/containers/record-modal.jsx +++ b/src/containers/record-modal.jsx @@ -73,22 +73,24 @@ class RecordModal extends React.Component { sampleRate: this.state.sampleRate, channelData: [clippedSamples] }).then(wavBuffer => { - const md5 = String(Math.floor(100000 * Math.random())); const vmSound = { format: '', - md5: `${md5}.wav`, + dataFormat: 'wav', name: `recording ${this.props.vm.editingTarget.sprite.sounds.length}` }; - // Load the encoded .wav into the storage cache + // Load the encoded .wav into the storage cache and get resulting + // md5 from storage const storage = this.props.vm.runtime.storage; - storage.builtinHelper.cache( + const md5 = storage.builtinHelper.cache( storage.AssetType.Sound, storage.DataFormat.WAV, new Uint8Array(wavBuffer), - md5 ); + // update vmSound object with md5 property + vmSound.md5 = `${md5}.${vmSound.dataFormat}`; + this.props.vm.addSound(vmSound).then(() => { this.props.onClose(); this.props.onNewSound();