mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
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:
parent
574749bbba
commit
da268ea0c1
2 changed files with 4 additions and 3 deletions
|
@ -11,9 +11,13 @@ class Scratch3SoundBlocks {
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
|
|
||||||
// Clear sound effects on green flag and stop button events.
|
// 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);
|
this._clearEffectsForAllTargets = this._clearEffectsForAllTargets.bind(this);
|
||||||
if (this.runtime) {
|
if (this.runtime) {
|
||||||
|
this.runtime.on('PROJECT_STOP_ALL', this.stopAllSounds);
|
||||||
this.runtime.on('PROJECT_STOP_ALL', this._clearEffectsForAllTargets);
|
this.runtime.on('PROJECT_STOP_ALL', this._clearEffectsForAllTargets);
|
||||||
|
this.runtime.on('STOP_FOR_TARGET', this._stopAllSoundsForTarget);
|
||||||
this.runtime.on('PROJECT_START', this._clearEffectsForAllTargets);
|
this.runtime.on('PROJECT_START', this._clearEffectsForAllTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1055,9 +1055,6 @@ class RenderedTarget extends Target {
|
||||||
*/
|
*/
|
||||||
onStopAll () {
|
onStopAll () {
|
||||||
this.clearEffects();
|
this.clearEffects();
|
||||||
if (this.sprite.soundBank) {
|
|
||||||
this.sprite.soundBank.stopAllSounds();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue