可用的浏览器,chrome
, firefox
, opera
, safari
暂不支持
<video src="" id="video" width=640 height=480 autoplay=""></video>
var constraints = {video: true}
var video = document.getElementById("video")
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
function successCallback(stream) {
window.stream = stream;
if(window.URL) {
video.src = window.URL.createObjectURL(stream);
} else if (window.webkitURL) {
video.src = window.webkitURL.createObjectURL(stream);
} else {
video.src = steam;
}
video.play()
}
function errorCallback(error) {
console.log("Video", error);
}
navigator.getUserMedia(constraints, successCallback, errorCallback);
网友评论