Open alandeg opened 10 months ago
Thanks for the detailed bug. That makes sense. Will look at it soon
I'm seeing this same issue, though my repro steps are slightly simpler
pauseAll()
stop()
on a specific sound instanceresumeAll()
I believe what's happening is that when pause()
is called on a sound, it's _internalStop()
is getting called, which is nulling this._source
, so when stop()
gets called while the sound is already paused, it checks if this._source
exists, it doesn't, and then nothing happens. I think if we were to emit the 'stop' event any time stop()
gets called, regardless of whether _source
exists, Sound
should trigger _onComplete()
and clean up any instances still in the _instances
array.
I've only looked at the v4 code, but here's the instance stop: https://github.com/pixijs/sound/blob/a84c2149e3c61fde7bec9284fdc2879a49d5230f/src/webaudio/WebAudioInstance.ts#L111-L115
and here's the _onComplete: https://github.com/pixijs/sound/blob/a84c2149e3c61fde7bec9284fdc2879a49d5230f/src/Sound.ts#L766-L776
I'm having some issues creating a fork right now, but this snippet seems to have fixed this issue in sound v4 in my project:
import { webaudio } from '@pixi/sound';
webaudio.WebAudioInstance.prototype.stop = function(){
if (this._source)
{
this._internalStop();
}
this.emit('stop');
}
I'm having the same issue, is there an ETA for the fix? Version 5.2.3.
Thank you!
I did some digging and problem seems to be lying in refreshPause
calls.
@nicolasalt Can you try changes from PR #270 a few times locally? It might be a candidate for fixing the issue.
I've tried but your PR is on top of pixi/sound v6.0 which depends on pixijs v8, while I'm using pixijs v7.2.4.
The context of this issue is related to the auto-pause feature introduces in a recent version of this library.
Steps to reproduce: 1) Start playing a sound 2) Blur the window 3) Something must stop the sound i.e. an event listener which calls
.stop()
4) Focus the window again 5) Observe the sound continues playing when it should notAs a workaround you must disable the auto pause feature using
PIXI.sound.disableAutoPause = true;
Example: https://stackblitz.com/edit/js-mhehrg?file=index.js