我正在构建一个允许从网络摄像头捕获和保存照片的平台,在localhost上可以很好地工作,但是将其安装在非本地服务器上时,对我来说不起作用。
function turnOnCamera(){
canvas = document.getElementById("resultado");
cxt = canvas.getContext("2d");
video = document.getElementById("camara");
if(!navigator.getUserMedia){
navigator.getUserMedia = navigator.getUserMedia || navigator.webKitGetUserMedia || navigator. moxGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
}
if(!window.ULR){
window.ULR = window.webkitURL;
}
console.log(navigator.getUserMedia);
if(navigator.getUserMedia){
navigator.getUserMedia({"video":true, "audio":false},
function(stream){
try{
localstream = stream;
video.srcObject = stream;
video.play();
}catch(error){
video.srcObject = null;
}
},function(err){
console.log("Error :" + err);
});
}else{
console.log("Error :" + "No getUsermedia");
}
}
控制台响应未定义