Skip to content

Commit b85e329

Browse files
committed
Merge branch 'uepr56-react18' of github.com:scratchfoundation/scratch-editor into UEPR-56-UEPR-282
2 parents d015a0e + 62dde2c commit b85e329

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/scratch-gui/src/containers/sound-editor.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,11 @@ const mapStateToProps = (state, {soundIndex}) => {
485485
const sound = state.scratchGui.vm.editingTarget.sprite.sounds[index];
486486
const audioBuffer = state.scratchGui.vm.getSoundBuffer(index);
487487
return {
488-
soundId: sound.soundId,
489-
sampleRate: audioBuffer.sampleRate,
490-
samples: audioBuffer.getChannelData(0),
488+
soundId: sound?.soundId,
489+
sampleRate: audioBuffer?.sampleRate,
490+
samples: audioBuffer?.getChannelData(0),
491491
isFullScreen: state.scratchGui.mode.isFullScreen,
492-
name: sound.name,
492+
name: sound?.name,
493493
vm: state.scratchGui.vm
494494
};
495495
};

packages/scratch-vm/src/virtual-machine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ class VirtualMachine extends EventEmitter {
797797
* @return {AudioBuffer} the sound's audio buffer.
798798
*/
799799
getSoundBuffer (soundIndex) {
800-
const id = this.editingTarget.sprite.sounds[soundIndex].soundId;
800+
const id = this.editingTarget.sprite.sounds[soundIndex]?.soundId;
801801
if (id && this.runtime && this.runtime.audioEngine) {
802802
return this.editingTarget.sprite.soundBank.getSoundPlayer(id).buffer;
803803
}

0 commit comments

Comments
 (0)