I am trying to pause and play an audio which was started with an offset. Instead of resuming from the position that it was paused, the audio restarts from the beginning. Repro is added in the playground below. The pause/play is done inside the onPointerUpObservable of the Issue button. After pausing and playing, I would expect the audio to resume at around 10 seconds. But instead, the audio restarts from 0 seconds
The issue seems to be coming from this line which doesn’t consider the current offset when assigning the _startOffset and this line which also ignores the offset if isPaused is true.
@docEdub Thanks a lot for the super fast response and fix. The pause / play seems to be working now. However, I now seem to be getting a new issue. When I try to restart an audio by calling play(0, 0) on a sound which has previously been started with an offset, it is not starting from 0 but from the previous offset. The relevant code and playground are added below
sound.play(0, 10);
sound.stop();
sound.play(0, 0) // I would expect this to start from 0, but it is starting from 10
Hi, @docEdub I think I might be running into another issue now (v5.42.1). When I try to get the current time of the audio, the return value seems to be different in the two scenarios below
Scenario 1
sound.pause();
sound.stop();
sound.play(0, 10);
console.log(sound.currentTime) // This gives a non-zero value
Scenario 2
sound.stop();
sound.play(0, 10);
console.log(sound.currentTime) // This always returns "0"
I don’t know if this is expected or not, but it doesn’t make sense to me that stopping while paused makes currentTime return a different value than stopping while not paused. I would expect the stop function to reset any state related to pause and always reset currentTime to zero.
@docEdub Apologies for the repeated posts, but I just checked the v5.43.0 release and think I’m getting into another issue. In the latest release, the currentTime after pausing an audio is always returning 0
Checked with v5.42.2 on PG and v5.43.0 on local. Is this an expected functionality or a bug?
P.S: I’m adding all issues here since it is easier to follow a single thread of fixes. Please let me know if I should be creating new thread for each issue, I’d be happy to do that.