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

HTML Audio/Video DOM error Property

HTML Audio/Video DOM error Property

HTML audio/video Tag Reference HTML Audio/Video DOM Reference

Example

Get the error state of the video:

myVid=document.getElementById("video1");

alert(myVid.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.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Only Internet Explorer 9 supports the error property.


Syntax

audio|video

.error.code

Return Value

Type Description
Number The code property of the MediaError object returns a numeric value representing the error state of the audio/video:
  • 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
  • |

    HTML audio/video Tag Reference HTML Audio/Video DOM Reference