各位大佬,请问一下为什么模拟的时候摄像头是可以调用的,但是发布了以后就不行了呢?
调用摄像头是用的页面加载时的JS命令
$("[fgcname=video]").empty();
$("[fgcname=video]").append("<video id='video' width='200' height='150'></video>");
$("[fgcname=canvas]").empty();
$("[fgcname=canvas]").append(" <canvas id='canvas' width='1280' height='720'></canvas>");
var video = document.getElementById('video'),
canvas = document.getElementById('canvas'),
img = document.getElementById('img'),
vendorUrl = window.URL || window.webkitURL;
navigator.getMedia = navigator.getUserMedia ||
navagator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
navigator.getMedia({
video: true,
audio: false
}, function(strem){
console.log(strem);
//video.src = vendorUrl.createObjectURL(strem);
video.srcObject = strem;
video.play();
}, function(error) {
//error.code
console.log(error);
});
|