Sound currentTime exceeds total duration in some cases

Hello,

I’m having a setup where I need to loop my audio, but cannot do loop:true in the Sound constructor due to a few constraints. So, I’m looping the audio by calling sound.play() inside sound.onEndedObservable. However, in this scenario, the currentTime seems to be exceeding the total duration of the sound when the below steps are followed:

  1. Start the sound with sound.play()
  2. Wait for some time
  3. Pause it with sound.pause()
  4. Call sound.play()
  5. Let the current loop play
  6. Check sound.currentTime in the next loop. The value exceeds sound.getAudioBuffer().duration towards the end

PG:

PG Repro steps:

  1. Open the PG and allow the sound to play for some time (Preferably wait till the Current Time > 5 sec)
  2. Click on the Pause-Play button
  3. Wait for the next loop. sound.currentTime will exceed sound.getAudioBuffer().duration towards the end of the loop. The green box on the right will become red when that happens

It seems to be happening because _currentTime is not being set to zero when the audio loops

@docEdub Any ideas?

Yep, easy fix. PR #13478 should take care of it.

1 Like