Video networkState Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video


The networkState property returns the current network state of the video.

Return Value

Type Description
Number Represents the current network state of the video element:
  • 0 = NETWORK_EMPTY - video has not yet been initialized
  • 1 = NETWORK_IDLE - video is active and has selected a resource, but is not using the network
  • 2 = NETWORK_LOADING - browser is downloading data
  • 3 = NETWORK_NO_SOURCE - no video source found

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

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

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

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

function myFunction() {/* w  w w.j a v a  2s .c  om*/
    var x = document.getElementById("myVideo").networkState;
    document.getElementById("demo").innerHTML = x;


Related Tutorials