Open In App

HTML | DOM Video error Property

Last Updated : 30 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The DOM Video error property is used to return the MediaError object and MediaError object contains error state of Video.

Syntax:

video.error.code

Return Type: This property returns a numbers which represents the error state of the video:

  • 1 = MEDIA_ERR_ABORTED – User aborted fetching process
  • 2 = MEDIA_ERR_NETWORK – error occurred at the time of downloading
  • 3 = MEDIA_ERR_DECODE – error occurred at the time of decoding
  • 4 = MEDIA_ERR_SRC_NOT_SUPPORTED – video are not supported

Example:




<!DOCTYPE html> 
<html
  
<head
    <title
        Video error Property 
    </title
</head
  
<body style="text-align: center"
  
    <h1 style="color: green"
        GeeksforGeeks 
    </h1>
   
    <h2 style="font-family: Impact"
        Video error Property 
    </h2
    <br
  
    <video id="Test_Video" width="360"
        height="240" controls> 
          
        <source id="mp4_source" src="sample2.mp4"
                type="video/mp4"
          
        <source id="ogg_source" src="sample2.ogg"
                type="video/ogg"
    </video
    <br
  
    <button ondblclick="My_Video()"
        Return Error State
    </button
  
    <p id="test"></p
  
    <script
        function My_Video() { 
            var v = document.getElementById( 
                   "Test_Video").error.code; 
              
            document.getElementById("test"
                   ).innerHTML = v; 
        
    </script
</body
  
</html>


Output:

Supported Browser: The browser supported by HTML DOM Video error Property are listed below:

  • Internet Explorer


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads