control sound stopping in scratch3_sound.js

- Stop sound playback for target when STOP_FOR_TARGET is emitted
- Stop all sounds when PROJECT_STOP_ALL is emitted
- RenderedTarget should not manage sound stopping in `stopAll`
This commit is contained in:
Michael "Z" Goddard 2018-10-02 13:04:54 -04:00
parent 574749bbba
commit da268ea0c1
No known key found for this signature in database
GPG key ID: 762CD40DD5349872
2 changed files with 4 additions and 3 deletions

View file

@ -11,9 +11,13 @@ class Scratch3SoundBlocks {
this.runtime = runtime;
// Clear sound effects on green flag and stop button events.
this.stopAllSounds = this.stopAllSounds.bind(this);
this._stopAllSoundsForTarget = this._stopAllSoundsForTarget.bind(this);
this._clearEffectsForAllTargets = this._clearEffectsForAllTargets.bind(this);
if (this.runtime) {
this.runtime.on('PROJECT_STOP_ALL', this.stopAllSounds);
this.runtime.on('PROJECT_STOP_ALL', this._clearEffectsForAllTargets);
this.runtime.on('STOP_FOR_TARGET', this._stopAllSoundsForTarget);
this.runtime.on('PROJECT_START', this._clearEffectsForAllTargets);
}

View file

@ -1055,9 +1055,6 @@ class RenderedTarget extends Target {
*/
onStopAll () {
this.clearEffects();
if (this.sprite.soundBank) {
this.sprite.soundBank.stopAllSounds();
}
}
/**