Get the current network state of the video:
var x = document.getElementById("myVideo").networkState;
Click the button to get the network state of the video.
<!DOCTYPE html> <html> <body> <video id="myVideo" width="100" height="100" controls autoplay> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> Your browser does not support the video tag. </video><br> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w . java 2 s. co m var x = document.getElementById("myVideo").networkState; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The networkState property returns the current network state of the video.
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 |