I will play a bit with the HTML5 <audio> , and I noticed some strange behavior related to the currentTime attribute.
I wanted the local audio file to play and the timeupdate event to timeupdate detected when it ends by comparing the currentTime attribute with the duration attribute.
It really works very well if I let the song play from beginning to end - the end of the song is determined correctly.
However, manually modifying currentTime (either directly using JavaScript or using browser-based controls) causes the API to no longer return the correct currentTime value, but seems to set it a few seconds ahead of the position that is actually playing.
(These "few seconds" ahead are based on Chrome, Firefox seems to be completely crazy, which leads to the discrepancy becoming larger.)
A small jsFiddle example about the problem: http://jsfiddle.net/yp3o8cyw/2/
Can someone tell me why this is happening - or I just didn't understand what the API should do?
PS: I just noticed that this only happens with MP3-encoded files, OGG files completely succeed.
source share