【发布时间】:2016-03-03 08:00:18
【问题描述】:
我正在使用 HTML Media Capture 和 getUserMedia 方法。它无法与 Chrome 一起使用,并且我收到了失败时包含的警报。
这是我使用的示例代码:
if (navigator.getUserMedia) {
navigator.getUserMedia(
// constraints
{
video: true,
audio: true
},
// successCallback
function (localMediaStream) {
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(localMediaStream);
// Do something with the video
video.play();
},
// errorCallback
function (err) {
console.log("The following error occured: " + err);
}
);
} else {
alert("getUserMedia not supported by your web browser or Operating system version");
}
【问题讨论】:
-
对于正确的 HTML 媒体捕获语法(有几个修订),请参阅 addpipe.com/blog/correct-syntax-html-media-capture
-
使用最新版本... navigator.getUserMedia() 现在替换为 navigator.mediaDevices.getUserMedia webrtc.github.io/samples
标签: javascript html google-chrome internet-explorer microsoft-edge