mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -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 effects = this.getSoundEffects(soundId);
|
||||||
const player = this.getSoundPlayer(soundId);
|
const player = this.getSoundPlayer(soundId);
|
||||||
|
|
||||||
this.playerTargets.set(soundId, target);
|
if (this.playerTargets.get(soundId) !== target) {
|
||||||
effects.setEffectsFromTarget(target);
|
// make sure to stop the old sound, effectively "forking" the output
|
||||||
effects.addSoundPlayer(player);
|
// 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.connect(effects);
|
||||||
|
|
||||||
player.play();
|
player.play();
|
||||||
|
|
||||||
return player.finished();
|
return player.finished();
|
||||||
|
|
Loading…
Reference in a new issue