The MediaError.code is a read-only unsigned short that represents the error:


var myError = mediaError.code


A constant that is one of the following:

Name Value Description
MEDIA_ERR_ABORTED 1 The fetching of the associated resource has been aborted by the user
MEDIA_ERR_NETWORK 2 A network error caused the resource to stop being fetched.
MEDIA_ERR_DECODE 3 A decoding error caused the resource to stop being fetched.
MEDIA_ERR_SRC_NOT_SUPPORTED 4 The associated resource has been detected to be not suitable.


var obj = document.createElement('video');
obj.onerror = function() {console.log("Error with media: " + obj.error.code);}


Specification Status Comment
WHATWG HTML Living Standard
The definition of 'MediaError.code' in that specification.
Living Standard Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 3.5 (1.9.1) 9 ? ?
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) ? (Yes) (Yes)

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API MediaError Property Read-only Reference