I am using WebRTC and socket.io for video calling.
The call is working fine but when I run the turn off camera function, the video stops but the light of my webcam remains on.
Here is the function for turning off the camera:
const mute = () => {
setMuteCamera(true);
navigator.mediaDevices
.getUserMedia({ video: false, audio: true })
.then((stream) => {
setStream(stream);
myVideo.current.srcObject = stream;
if (stream != null) {
stream?.getTracks().forEach((track) => {
track.stop();
});
}
});
};