html5 - How to turn off the local camera when using the getUserMedia method?
女神的闺蜜爱上我2017-06-10 09:48:52
0
2
1110
I used the navigator.mediaDevices.getUserMedia() method to open the local camera. I need to close it after taking the photo, but how to close it? Help...
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
var track = stream.getTracks()[0]; // if only one media track
// ...
track.stop();
}).catch(function(err) {
/* handle the error */
});
stream is the instance in getUserMedia onSuccess callback
Please refer to the documentation