HTML | DOM Video error Property

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

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

  • Internet Explorer


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.