Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MediaRecorderErrorEvent
  4. error

MediaRecorderErrorEvent: error property

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see thecompatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

Theerror read-only property of theMediaRecorderErrorEvent interface is aDOMException object providing details about the exception that was thrownby aMediaRecorder instance.

When aMediaRecorderErrorEvent occurs, you can determine to some extentwhat went wrong by examining theerror property within theMediaRecorderErrorEvent received by theMediaRecorder'serror event handler,onerror.

Value

ADOMException describing the error represented by the event. Theerror'sname property's value may be any exceptionthat makes sense during the handling of media recording, including these specificallyidentified by the specification. The descriptions here are generic ones; you'll findmore specific ones to various scenarios in which they may occur in the correspondingmethod references.

InvalidStateError

An operation was attempted in a context in which it isn't allowed, or a request hasbeen made on an object that's deleted or removed.

NotSupportedError

AMediaRecorder couldn't be created because the specified optionsweren't valid. Themessage attribute should provide additionalinformation, if it exists.

SecurityError

TheMediaStream is configured to disallow recording. This may be thecase, for example, with sources obtained usinggetUserMedia() when the user denies permission to use an input device.

InvalidModificationError

The number of tracks on the stream being recorded has changed. You can't add orremove tracks while recording media.

UnknownError

A non-security related error occurred that cannot otherwise be categorized.Recording stops, theMediaRecorder'sstate becomesinactive,one lastdataavailable event issent to theMediaRecorder with the remaining received data, and finally astop event is sent.

Examples

Basic error-handling example

This function creates and returns aMediaRecorder for a givenMediaStream, configured to buffer data into an array and to watch forerrors.

js
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 = (event) => {    bufferList.push(event.data);  };  recorder.onerror = (event) => {    console.error(`Error: ${event.error}`);  };  recorder.start(100); /* 100ms time slices per buffer */  return recorder;}

Specifications

This feature is no longer part of any specification, and longer on track to become standard.

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp