I have a JS program that plays an audio until the very end.
I noticed than audio.duration slightly changes at the end of the audio, seemingly to have 0 <= audio.currentTime <= audio.duration
always hold true :
let audio = new Audio(...)
audio.play()
function printAudioDuration() {
window.requestAnimationFrame(() => {
console.log(audio.duration)
printAudioDuration()
)
}
That results in :
132.623667
132.623667
132.623667
...
132.623667
132.623673
And if I print audio.currentTime along the way, I always get a timestamp smaller than 132.623667, except for the last one, which exactly equals 132.623673.
Is this a documented behavior ? Am I doing something wrong ?
1