PixiJS Sound v4.4.1 has a pause/resume issue when working with spritemaps. Pausing and resuming a sound causes unexpected behavior, such as jumping to the next sound in the spritemap instead of restarting the current sound.
I believe that this issue arises because the internal _elapsed time scales according to the entire spritemap, and the AudioBufferSourceNode API lacks native pause/resume functionality. The known workaround is to manually control the playbackRate property of the AudioBufferSourceNode.
It has a detailed description of the issue, the use-case applied, and a an option to test the workaround as a well a fix for the elapsed time.
In the repro repository, the WebAudioNode instance is used to toggle paused state. I'm not 100% sure that this is an intended way. When you run the repro project, open it in your browser and follow the instructions to experience the problem.
Description
PixiJS Sound v4.4.1 has a pause/resume issue when working with spritemaps. Pausing and resuming a sound causes unexpected behavior, such as jumping to the next sound in the spritemap instead of restarting the current sound.
I believe that this issue arises because the internal
_elapsed
time scales according to the entire spritemap, and theAudioBufferSourceNode
API lacks native pause/resume functionality. The known workaround is to manually control theplaybackRate
property of theAudioBufferSourceNode
.Reproduction
I've created a repro repository here: https://github.com/nizamiza/pixi-sound-pause-resume-issue-repro
It has a detailed description of the issue, the use-case applied, and a an option to test the workaround as a well a fix for the elapsed time.
In the repro repository, the
WebAudioNode
instance is used to togglepaused
state. I'm not 100% sure that this is an intended way. When you run the repro project, open it in your browser and follow the instructions to experience the problem.Let me know if you need any additional info.
Packages info
pixi.js
version:6.4.2
@pixi/sound
version:4.4.1