3

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?

nomadSK25
  • 2,350
  • 3
  • 25
  • 36
Saran Kumar
  • 49
  • 1
  • 5

2 Answers2

3

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

mediaStream.getAudioTracks()[0].stop();
mediaStream.getVideoTracks()[0].stop();
vivekvw
  • 113
  • 1
  • 1
  • 6
0

You must have more than one stream instances. What you can do is to have a single instance of stream, you can store it on redux or context and call it when you need it accordingly.