I am using react-webcam to capture photos through webcam. I am able to stop the stream of the webcam but the camera indicator does not turn off even after the stream has been stopped. It turns off when I reload the page. Here's the function I am using to stop the stream.
function stopStreamedVideo() {
let videoElem = document.querySelector("#camera-content > video");
const stream = videoElem.srcObject;
const tracks = stream.getTracks();
tracks.forEach(function (track) {
track.stop();
});
videoElem.srcObject = null;
}