只读 error property in the MediaRecorderErrorEvent 接口是 DOMException object providing details about the exception that was thrown by a MediaRecorder 实例。

Media​Recorder​Error​Event occurs, you can determine to some extent what went wrong by examining the error property within the Media​Recorder​Error​Event received by the MediaRecorder 's error event handler, onerror .

句法

error = MediaRecorderErrorEvent.error;
					

A DOMException describing the error represented by the event. The error's 名称 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.

InvalidStateError

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

NotSupportedError
A MediaRecorder couldn't be created because the specified options weren't valid. The message atttribute should provide additional information, if it exists.
SecurityError
MediaStream 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;
}
					

规范

规范 状态 注释
MediaStream 录制
The definition of 'MediaRecorderErrorEvent.error' in that specification.
工作草案 最初的规范。

浏览器兼容性

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.

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
error Chrome No
不支持 No
Uses a generic event with an error 特性。
Edge No
不支持 No
Uses a generic event with an error 特性。
Firefox 57 IE No Opera No
不支持 No
Uses a generic event with an error 特性。
Safari No WebView Android No Chrome Android No
不支持 No
Uses a generic event with an error 特性。
Firefox Android 57 Opera Android No
不支持 No
Uses a generic event with an error 特性。
Safari iOS No Samsung Internet Android No
不支持 No
Uses a generic event with an error 特性。

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. MediaStream 录制 API
  2. MediaRecorderErrorEvent
  3. 构造函数
    1. MediaRecorderErrorEvent()
  4. 特性
    1. error
  5. Related pages for MediaStream Recording
    1. BlobEvent
    2. MediaRecorder

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1