mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 05:53:43 -05:00
Better order of stop/connect/play
This commit is contained in:
parent
ea6093835c
commit
c8f3510713
1 changed files with 9 additions and 3 deletions
|
@ -90,11 +90,17 @@ class SoundBank {
|
|||
const effects = this.getSoundEffects(soundId);
|
||||
const player = this.getSoundPlayer(soundId);
|
||||
|
||||
this.playerTargets.set(soundId, target);
|
||||
effects.setEffectsFromTarget(target);
|
||||
effects.addSoundPlayer(player);
|
||||
if (this.playerTargets.get(soundId) !== target) {
|
||||
// make sure to stop the old sound, effectively "forking" the output
|
||||
// when the target switches before we adjust it's effects
|
||||
player.stop();
|
||||
}
|
||||
|
||||
this.playerTargets.set(soundId, target);
|
||||
effects.addSoundPlayer(player);
|
||||
effects.setEffectsFromTarget(target);
|
||||
player.connect(effects);
|
||||
|
||||
player.play();
|
||||
|
||||
return player.finished();
|
||||
|
|
Loading…
Reference in a new issue