English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Directory

HTML Audio/Video DOM networkState attribute

The networkState attribute represents the current state of media acquisition on the network.

 HTML Audio/Video DOM Reference Manual

Online Example

Get the current network state of the video:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Audio/Video networkState attribute usage-Basic Tutorial(oldtoolbag.com)</<title>
</<head>
<body>
<button onclick="getNWState()" type="button">Get the current network state of the video</button>
<br> 
<video id="video1" controls="controls" autoplay="autoplay">
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support HTML5 video tag.
</video>
<script>
myVid = document.getElementById("video"1);
function getNWState()
{"}} 
  alert(myVid.networkState);
} 
</script> 
</body>
</html>
Test to see ‹/›

Definition and Usage

The networkState property returns audio/The current network state of the video (active).

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the networkState property.

Note:Internet Explorer 8 And earlier versions do not support this property.

Syntax

audio|video.networkState

Return value

TypeDescription
NumberRepresents audio/The current network state of the video element is:
  • 0 = NETWORK_EMPTY - Audio/Video has not been initialized

  • 1 = NETWORK_IDLE - Audio/Video is active and the resource is selected, but no network is used

  • 2 = NETWORK_LOADING - Browser is downloading data

  • 3 = NETWORK_NO_SOURCE - Audio not found/Video Source

 HTML Audio/Video DOM Reference Manual