Feng Huo Feng Huo - 1 year ago 80
Javascript Question

Tell whether video is loaded or not in Javascript

So, I've been using a listener on


to see if it's greater than
for when a video's loaded or not. This works for a very small video, and only in Google Chrome. It doesn't work in Firefox at all. Any ideas for how to get this to work?

I essentially want to wait till 3 seperate videos are loaded to take a specific action, how do I go about this?

Answer Source

Try this:

var video = document.getElementById("video-id-name");

if ( video.readyState === 4 ) {
    // it's loaded

Read here: https://developer.mozilla.org/en/DOM/HTMLMediaElement

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download