关于页面调用摄像头的问题
用html5调用摄像头截图的,之前用的时候是可以的,现在不知道怎么不行了,摄像头调用不了,js报错:getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS,不知道是什么原因,js代码如下:
var video = document.getElementById("video");
var errocb = function () {
console.log('sth wrong!');
};
if(navigator.getUserMedia) { // 标准的API
navigator.getUserMedia({ "video": true }, function (stream) {
video.src = stream;
video.play();
}, errocb);
}
else if (navigator.webkitGetUserMedia) { // WebKit 核心的API
navigator.webkitGetUserMedia({ "video": true }, function (stream) {
video.src = window.webkitURL.createObjectURL(stream);
video.play();
}, errocb);
}