navigator.mediaDevices captures the camera and other applications cannot use it; even when I do video.stop, other applications show "the camera is already in use".
const getMedia = async constraints => {
try {
stream = await navigator.mediaDevices.getUserMedia(constraints);
videoRef.current && (videoRef.current.srcObject = stream);
if (togle) {
videoRef.current.play();
}
if (!togle) {
stream.active &&
stream.getTracks().forEach(function (track) {
// videoRef.current.srcObject = null
track.stop();
});
}
videoRef.current && console.log(videoRef.current.srcObject);
} catch (err) {
console.log(err);
}
};