Skip to content
Related Articles

Related Articles

HTML | DOM Audio error Property
  • Last Updated : 30 Nov, 2019

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:




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

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

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :