Turn on camera
Note: Turning on the camera requires the browser website to be set to the inquiry state. If it is in the rejection state, it cannot be turned on.
Calling method navigator.mediaDevices.getUserMedia(
const constrains = {
video: true,
audio: true
}
navigator.mediaDevices.getUserMedia(constrains)
.then(stream => {
console.log('得到stream的类型是MediaStream')
}).catch(err => {
console.log(err, 拒绝)
})
Turn off camera
var mediaStreamTrack = stream.getTracks()[0];
mediaStreamTrack.stop();