Audio error attribute

Definition and usage

error The property returns a MediaError object.

The MediaError object provides a code property that contains the audio error state.

Note:This property is read-only.

Example

Get the audio error state:

var x = document.getElementById("myAudio").error.code;

Try it yourself

Syntax

audioObject.error.code

Return value

Type Description
Number

The code property of the MediaError object returns a number representing the audio error state:

  • 1 = MEDIA_ERR_ABORTED - The process was aborted by the user
  • 2 = MEDIA_ERR_NETWORK - Error occurred during download
  • 3 = MEDIA_ERR_DECODE - Error occurred during decoding
  • 4 = MEDIA_ERR_SRC_NOT_SUPPORTED - Audio is not supported

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Not Supported 9.0 Not Supported Not Supported Not Supported