如何getUserMedia
在webRTC中停止使用网络摄像头(与摄像头关闭连接) ?
我试过:localStream.getVideoTracks()[0].stop();
但它在 chrome 中对我不起作用。与相机的连接照原样继续。
我的代码是
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia ||
navigator.msGetUserMedia || navigator.oGetUserMedia;
if(navigator.getUserMedia){
navigator.getUserMedia({video: true}, handleVideo, videoError);
}
function handleVideo(stream) {
localStream = stream;
document.querySelector('#vidDisplay').src = window.URL.createObjectURL(stream);
};
function videoError(e)
{
alert("There is some problem..");
};