I am using webcam and microphone for my app. I want to release both the devices when I finish with the video and audio part. Webcam light is on, till the time I explicitly stop sharing it or refresh the page.
I tried implementing answers given in this question but without any luck - Stop/Close webcam which is opened by navigator.getUserMedia
var MediaStream = window.MediaStream;
if (typeof MediaStream === 'undefined' && typeof webkitMediaStream !== 'undefined') {
MediaStream = webkitMediaStream;
}
/*global MediaStream:true */
if (typeof MediaStream !== 'undefined' && !('stop' in MediaStream.prototype)) {
MediaStream.prototype.stop = function() {
this.getAudioTracks().forEach(function(track) {
track.stop();
});
this.getVideoTracks().forEach(function(track) {
track.stop();
});
};
}
I am not sure what's wrong.