Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off/stop browser camera in my sample react video call application

I am developing a video chat web application using react.js and kurento utils SDK for the media server. The problem is that the camera/light is still ON even after the video call is ended.The camera stops only for the first time and the problem occurs only from the second call.

  let stream = videoElem.srcObject;
  let tracks = stream.getTracks();

  tracks.forEach(function(track) {
    track.stop();
  });

  videoElem.srcObject = null;
}

I tried every possible ways to solve this issue and the above code is what i used for stopping camera.Is this a problem with react.js?

like image 537
Saran Kumar Avatar asked Feb 15 '26 18:02

Saran Kumar


1 Answers

Can you try stopping individual video and audio track as webrtc APIs e.g.

mediaStream.getAudioTracks()[0].stop();
mediaStream.getVideoTracks()[0].stop();
like image 113
vivekvw Avatar answered Feb 17 '26 06:02

vivekvw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!