Answer the question
In order to leave comments, you need to log in
How to know the duration of a YouTube video before it starts playing?
I can't figure out why I have all the videos 1 second longer before they start playing.
Codepen.io example
Line 85: console.log(Math.floor(player.getDuration()));
By F12 we open the Console and see 17 sec, this is already rounded up from 16.7 sec.
Next, run the video, and get 16 seconds!
How so?
And this is with almost any video. 1 sec is certainly not critical, but somehow it hurts the eye.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question