MediaRecorder: error event - Web APIs 编辑
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
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论