How do I check if my Audio/Video file is loaded or not? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

How do I check if my Audio/Video file is loaded or not?

I wanted to show a loading gif when my audio/video file is loading but I can't find a proper way to check if it is loaded or not. Any syntax in JavaScript to this problem?

6th May 2019, 6:12 PM
Jaagrav
Jaagrav - avatar
1 Answer
+ 1
video.addEventListener('progress', function() { var loadedPercentage = this.buffered.end(0) / this.duration; ... // suggestion: don't use this, use what's below }); // Font: https://stackoverflow.com/questions/5029519/html5-video-percentage-loaded
13th May 2019, 12:24 AM
Jônatas Araripe
Jônatas Araripe - avatar