Reputation: 159
I am using navigator.mediaDevices.getUserMedia({ audio: true, video: true })
to ask for permission to use my users' mic and webcam in advance and it works, however, it causes the webcam to light up (which might look like the app is recording or using the camera when it's not). Unless by asking permission I am forcing the camera to be used which I am not sure about. My questions are:
Upvotes: 6
Views: 10026
Reputation: 15268
Demo here: https://js.do/code/so62273679
Take the stream, get the tracks and stop them to turn off the camera. Camera will still flash, but it will turn off.
navigator.getUserMedia({audio:true,video:true}, function(stream) {
stream.getTracks().forEach(x=>x.stop());
}, err=>console.log(err));
Upvotes: 5