mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-11 04:51:15 -04:00
Stop all sounds in the sound bank in stopAllSounds
This commit is contained in:
parent
f5ce73ae51
commit
562b01a988
1 changed files with 13 additions and 2 deletions
|
@ -229,8 +229,19 @@ class Scratch3SoundBlocks {
|
|||
stopAllSounds () {
|
||||
if (this.runtime.targets === null) return;
|
||||
const allTargets = this.runtime.targets;
|
||||
for (let i = 0; i < allTargets.length; i++) {
|
||||
this._stopAllSoundsForTarget(allTargets[i]);
|
||||
for (const target of allTargets) {
|
||||
if (target.sprite.soundBank) {
|
||||
// stopAllSounds default to ALL_TARGETS.
|
||||
// This function is supposed to stop all sounds, so it should be fine.
|
||||
// Because of some weird clone handlings, SoundBank.playerTargets can
|
||||
// contain targets that are no longer in runtime.targets.
|
||||
// For this reason, passing targets to stopAllSounds is unreliable,
|
||||
// so _stopAllSoundsForTarget is not used.
|
||||
target.sprite.soundBank.stopAllSounds();
|
||||
if (this.waitingSounds[target.id]) {
|
||||
this.waitingSounds[target.id].clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue