mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 22:12:48 -05:00
fix: fix taking a SoundPlayer's state
This commit is contained in:
parent
5c822e6542
commit
90589b861d
1 changed files with 13 additions and 10 deletions
|
@ -102,16 +102,18 @@ class SoundPlayer extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const taken = new SoundPlayer(this.audioEngine, this);
|
const taken = new SoundPlayer(this.audioEngine, this);
|
||||||
|
taken.playbackRate = this.playbackRate;
|
||||||
|
if (this.isPlaying) {
|
||||||
|
taken.isPlaying = this.isPlaying;
|
||||||
|
taken.initialize();
|
||||||
|
taken.outputNode.disconnect();
|
||||||
taken.outputNode = this.outputNode;
|
taken.outputNode = this.outputNode;
|
||||||
if (this.volumeEffect !== null) {
|
taken.outputNode.addEventListener(ON_ENDED, taken);
|
||||||
taken.volumeEffect.set(this.volumeEffect.value);
|
taken.volumeEffect.set(this.volumeEffect.value);
|
||||||
}
|
|
||||||
if (this.target !== null) {
|
if (this.target !== null) {
|
||||||
taken.connect(this.target);
|
taken.connect(this.target);
|
||||||
}
|
}
|
||||||
taken.initialized = this.initialized;
|
}
|
||||||
taken.isPlaying = this.isPlaying;
|
|
||||||
taken.playbackRate = this.playbackRate;
|
|
||||||
|
|
||||||
if (this.isPlaying) {
|
if (this.isPlaying) {
|
||||||
this.emit('stop');
|
this.emit('stop');
|
||||||
|
@ -123,9 +125,10 @@ class SoundPlayer extends EventEmitter {
|
||||||
this.volumeEffect.dispose();
|
this.volumeEffect.dispose();
|
||||||
}
|
}
|
||||||
this.volumeEffect = null;
|
this.volumeEffect = null;
|
||||||
this.target = null;
|
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
this.isPlaying = false;
|
this.isPlaying = false;
|
||||||
|
|
||||||
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
play () {
|
play () {
|
||||||
|
|
Loading…
Reference in a new issue