SoundFile onended triggered when SoundFile pause method is called.
ISSUE
If the SoundFile has an onended function registered, it will trigger the function when the SoundFile pause method is called even if the SoundFile has not reached his end.
AFFECTED
library: p5.soundjs 0.3.11 browsers: Firefox, Chrome, Safari, Android Firefox, Android Chrome.
POC
Here you can find a simple sketch on the p5 web editor that demonstrate the issue I'm experiencing.
https://editor.p5js.org/6160/sketches/1bN8O4gl0
WORKAROUND
I've managed to resolve this issue on my sketch by adding a flag and checking manually if the SoundFile has been paused.
I was expecting the onended function to be triggered only at the end of the SoundFile, am i missing something?
EDIT: i've corrected the lib version
@6160 great find 👍, A/q https://p5js.org/reference/#/p5.SoundFile/onended It seems as onended() hooks will only be fired if buffer Length is empty... @therewasaguy i donot think that pausing a sound clears the buffer, So ya its ambiguity if it happens that way!
I think it should be fixed, like seeting a flag to check if it is paused and then not to fire the onended hook!!
I'm having the same issue. I've just tried different versions of p5.sound. The same issue happens on the latest version of the lib (0.3.12) and all the way back to p5.sound 0.3.7. I stopped checking previous versions after that.