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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
error event | Chrome Full support 49 | Edge Full support 79 | Firefox Full support 25 | IE No support No | Opera Full support 36 | Safari No support No | WebView Android Full support 49 | Chrome Android Full support 49 | Firefox Android Full support 25 | Opera Android Full support 36 | Safari iOS No support No | Samsung Internet Android Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support