The read-only error property in the MediaRecordingErrorEvent interface is a DOMException object providing details about the exception that was thrown by a MediaRecorder instance.
When a MediaRecordingErrorEvent occurs, you can determine to some extent what went wrong by examining the error property within the MediaRecorderErrorEvent received by the MediaRecorder's error event handler, onerror.
error = MediaRecorderErrorEvent.error;
A DOMException describing the error represented by the event. The error's error property's value may be any exception that makes sense during the handling of media recording, including these specifically identified by the specification. The descriptions here are generic ones; you'll find more specific ones to various scenarios in which they may occur in the corresponding method references.
InvalidStateErrorNotSupportedErrorMediaRecorder couldn't be created because the specified options weren't valid. The message atttribute should provide additional information, if it exists.SecurityErrorMediaStream is configured to disallow recording. This may be the case, for example, with sources obtained using getUserMedia() when the user denies permission to use an input device. This also happens when a MediaStreamTrack within the stream is marked as isolated due to the peerIdentity constraint on the source stream.This function creates and returns a MediaRecorder for a given MediaStream, configured to buffer data into an array and to watch for errors.
function recordStream(stream) {
let recorder = null;
let bufferList = [];
try {
recorder = new MediaRecorder(stream);
} catch(err) {
/* exception while trying to create the recorder; handle that */
}
recorder.ondataavailable = function(event) {
bufferList.push(event.data);
};
recorder.onerror = function(event) {
let error = event.error;
};
recorder.start(100); /* 100ms time slices per buffer */
return recorder;
} | Specification | Status | Comment |
|---|---|---|
| MediaStream Recording The definition of 'MediaRecordingErrorEvent.error' in that specification. | Working Draft | Initial specification. |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | No
|
No | 57 | No | No
|
No |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | No | No
|
No | 57 | No
|
No | No |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorderErrorEvent/error