I am working with HTML5 audio. For my use-case, I need to listen on the audio duration played and once it crosses a certain threshold, pause the audio. So something like:
$(audio).bind('timeupdate', function() {
if (audio.currentTime >= 10){
audio.pause();
}
});
What I am noticing is that by the time my handler executes, audio.currentTime
is around 10.12878
, 10.34023
etc and hence, some little extra audio is played before it is paused.
Another question seems to have documented the same issue.The question is dated in 2012 so I am wondering if the state of the art has improved.
If not, what other ways exist to do this with more precision? I haven't worked with audio much before and I would really appreciate the help.