Why does video duration doesn't always appear in JavaScript after refresh?

Viewed 19

I have a playlist of videos made with video.js and JavaScript (to automatically play next video, to view each video duration, and so on..)

The videos durations appear correctly, but most of the times, if I refresh the page, most or all of them disappear (nothing appears, not even NaN).

I made duration.js just for the purpose of getting the duration and writing it for each video. and I called it as a last script after video.js cdn and with a defer tag.

I also have vid.js to create a video.js instance, video settings like aspect ratio, and for other stuff like "page dark theme, video controls, etc..."

everything works fine except for the issue mentioned above.

here's a demo of how the page looks like: https://cheerful-bienenstitch-239dd7.netlify.app/lessons.html

another note: if I refresh with the console open, the durations would appear correctly !!

here's the code uploaded on GitHub"

https://github.com/Mohammad271091/video-playlist

NOTE: If the code should be posted here, please let me know I would add it here ..

THANKs

0 Answers
Related