MediaRecorder: error event

The MediaRecorder interface's error event is fired when an error occurs: for example because recording wasn't allowed or was attempted using an unsupported codec.

Bubbles No
Cancelable No
Interface MediaRecorderErrorEvent
Event handler property onerror

For details of the all the possible errors see the documentation for the event handler property: onerror.

Examples

Using addEventListener to listen for error events:

async function record() {
    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
    const recorder = new MediaRecorder(stream);
    recorder.addEventListener('error', (event) => {
        console.error(`error recording stream: ${event.error.name}`)
    });
    recorder.start();
}

record();

The same, but using the onerror event handler property:

async function record() {
    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
    const recorder = new MediaRecorder(stream);
    recorder.onerror = (event) => {
        console.error(`error recording stream: ${event.error.name}`)
    };
    recorder.start();
}

record();

Specifications

Specification Status
MediaStream Recording Working Draft

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
error eventChrome Full support 47
Notes Disabled
Full support 47
Notes Disabled
Notes Full support since Chrome 49.
Disabled From version 47: this feature is behind the Experimental Web Platform features preference (needs to be set to Enabled). To change preferences in Chrome, visit chrome://flags.
Edge ? Firefox Full support 25IE ? Opera Full support 36Safari ? WebView Android Full support 49Chrome Android Full support 49Edge Mobile ? Firefox Android Full support 25Opera Android Full support 36Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Document Tags and Contributors

Tags: 
Contributors to this page: wbamberg
Last updated by: wbamberg,