I work with HTML5 audio. For my use case, I need to listen to the duration of the sound, and when it crosses a certain threshold, pause the sound. So something like:
$(audio).bind('timeupdate', function() { if (audio.currentTime >= 10){ audio.pause(); } });
What I notice is that by the time my audio.currentTime handler is audio.currentTime is around 10.12878 , 10.34023 , etc., and therefore, a little extra sound is played before pausing it.
Another question seems to have documented the same problem. The question is dated 2012, so I wonder if the current state has improved.
If not, are there other ways to do this with greater accuracy? I have not worked with audio before, and I am very grateful for the help.
Rajat source share