How to stop webcam (Close connection with camera) using getUserMedia
in webRTC?
I tried with : localStream.getVideoTracks()[0].stop();
But it will not work for me in chrome. connection with the camera continues as it is.
My code is
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..");
};