Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Audio error attribute

Audio error attribute

Audio Object Reference Audio object

Example

Get the error status of the audio:

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

Try it »


Definition and Usage

The error attribute returns a MediaError object.

The code attribute of the MediaError object contains the error status of the audio/video.

Note: This attribute is read-only.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Currently only Internet Explorer supports the error attribute.

Note: Internet Explorer 8 and earlier IE versions do not support this attribute.


Syntax

audioObject

.error.code

Return Value

Type Description
Numeric value

The code attribute of the MediaError object returns a numeric value indicating the error status of the audio:

  • 1 = MEDIA_ERR_ABORTED - the retrieval process was aborted by the user
  • 2 = MEDIA_ERR_NETWORK - an error occurred during download
  • 3 = MEDIA_ERR_DECODE - an error occurred during decoding
  • 4 = MEDIA_ERR_SRC_NOT_SUPPORTED - audio/video not supported
  • |

    Audio Object Reference Audio object