I'm playing around a bit with the HTML5 <audio>
tag and I noticed some strange behaviour that has to do with the currentTime
attribute.
I wanted to have a local audio file played and let the timeupdate
event detect when it finishes by comparing the currentTime
attribute to the duration
attribute.
This actually works pretty fine if I let the song play from the beginning to the end - the end of the song is determined correctly.
However, changing the currentTime
manually (either directly through JavaScript or by using the browser-based audio controls) results in the API not giving back the correct value of the currentTime
anymore but seems to set it some seconds ahead of the position that's actually playing.
(These "some seconds" ahead are based on Chrome, Firefox seems to completely going crazy which results in the discrepancy being way bigger.)
A little jsFiddle example about the problem: http://jsfiddle.net/yp3o8cyw/2/
Can anybody tell me why this happens - or did I just not getting right what the API should do?
P.S.: I just noticed this actually only happens with MP3-encoded files, OGG files are totally doing fine.