Video readyState Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video


The readyState property returns the current ready state of the video.

This property is read-only.

Return Value

Type Description
Number Represents the ready state of the video element:
  • 0 = HAVE_NOTHING - no information
  • 1 = HAVE_METADATA - metadata for the video is ready
  • 2 = HAVE_CURRENT_DATA - data for the current playback position is ready, but not enough data to play next frame/millisecond
  • 3 = HAVE_FUTURE_DATA - data for the current and at least the next frame is available
  • 4 = HAVE_ENOUGH_DATA - enough data available to start playing

The following code shows how to get the current ready state of the video:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<video id="myVideo" width="320" height="240" controls>
  <source src="your.mp4" type="video/mp4">
  <source src="your.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>//  www  .  ja va2s  . com

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myVideo").readyState;
    document.getElementById("demo").innerHTML = x;


Related Tutorials