HTML | DOM Audio error Property

The DOM Audio error property is used to returns MediaError object and MediaError object contains error state of Video.

Syntax:

audio.error.code

Return Type:
Numbers: The MediaError Object returns a number representing 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 – audio are not supported

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
  
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h2>DOM Audio error Property</h2>
        <audio id="my_Audio" controls autoplay>
            <source id="mp4_src"
                    src="gfg.ogg"
                    type="audio/mp3">
  
        </audio>
        <br>
        <button onclick="myAudio()" type="button">
            Click It
        </button>
        <br>
  
        <script>
            var a = document.getElementById("my_Audio");
  
            function myAudio() {
                alert("error: " + a.error.code);
            }
        </script>
    </center>
</body>
  
</html>

chevron_right


Output:

  • Before Click on Button:
  • After Click on Button:

Supported Browser: The browsers supported by HTML DOM Audio 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.