From a6d17fcba322d9cda089087cd1dbdd35b0eea09a Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Wed, 20 Dec 2017 14:00:23 -0500 Subject: [PATCH] Stop all sounds for all targets --- src/blocks/scratch3_sound.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/blocks/scratch3_sound.js b/src/blocks/scratch3_sound.js index 29b0de06f..ea8c5e865 100644 --- a/src/blocks/scratch3_sound.js +++ b/src/blocks/scratch3_sound.js @@ -167,9 +167,17 @@ class Scratch3SoundBlocks { return -1; } - stopAllSounds (args, util) { - if (util.target.audioPlayer === null) return; - util.target.audioPlayer.stopAllSounds(); + stopAllSounds () { + if (this.runtime.targets === null) return; + const allTargets = this.runtime.targets; + for (let i = 0; i < allTargets.length; i++) { + this._stopAllSoundsForTarget(allTargets[i]); + } + } + + _stopAllSoundsForTarget (target) { + if (target.audioPlayer === null) return; + target.audioPlayer.stopAllSounds(); } setEffect (args, util) {