p5.js-sound icon indicating copy to clipboard operation
p5.js-sound copied to clipboard

p5 sound.stop() - currentTime() not set to zero

Open atagger opened this issue 4 years ago • 0 comments

I think there is something wrong / buggy in p5 sound.stop(). This may have been reported on another issue. When you hit stop it should return zero for currentTime(), unless I am misunderstanding the intended behavior. This can be a major issue depending on your application, but I am using "_lastpos" in the sound constructor to reset the time manually.

Here is an example of stopping the song not giving zero. You would expect it to return the currentTime() value if using something like pause(), but with stop(), you would expect this value to be a 0.

sound.stop();
console.log(sound.currentTime());
sound.play();
console.log(sound.currentTime());

something I am using that works:

sound.stop(); sound._lastPos=0; console.log(sound.currentTime()); sound.play(); console.log(sound.currentTime());

this gives you zero, which is correct for my application. Any advice appreciated.

atagger avatar Aug 04 '21 20:08 atagger