Twilio-video.js: beta 5 - removetrack does not close webcam

Created on 5 Apr 2017  路  2Comments  路  Source: twilio/twilio-video.js

Hi,
I'm trying to stop local audio/video(not to disconnect from a room but just to stop the local audio/video).
I tried the following code and it does stop sending the audio/video, the problem is that the webcam light is still on, like it is still broadcasting the video.

var tracks = Array.from(room.localParticipant.tracks.values());
tracks.forEach(function(track) {
    room.localParticipant.removeTrack(track);
});
bug

Most helpful comment

Thanks for the report @theDude30 & @adriantombu,

To be clear,

  • Expected behavior when the Room is disconnected: LocalTracks should be stopped (i.e. webcam light should go off) _if_ the user isn't managing the LocalTracks themselves (i.e. they did not set the tracks property when calling connect).
  • Calling removeTrack after a LocalTrack is removed should not throw (currently getting a "TypeError: Cannot read property 'forEach' of undefined"). @manjeshbhargav's change in https://github.com/twilio/twilio-video.js/commit/e20d86e217b445fbc2c95cb511a0a8289ffa14ee should fix this.

As a workaround for now, you can call

room.localParticipant.tracks.forEach(track => track.stop());

All 2 comments

Well, I was about to report the same problem. Even with the disconnect() and the removeTrack(track), I keep getting the light of the webcam and Chrome still shows the recording icon in the tab.

I'm working on MacOS 10.12.4 with Google Chrome 58.0.3029.41 beta (64-bit).

Thanks for the report @theDude30 & @adriantombu,

To be clear,

  • Expected behavior when the Room is disconnected: LocalTracks should be stopped (i.e. webcam light should go off) _if_ the user isn't managing the LocalTracks themselves (i.e. they did not set the tracks property when calling connect).
  • Calling removeTrack after a LocalTrack is removed should not throw (currently getting a "TypeError: Cannot read property 'forEach' of undefined"). @manjeshbhargav's change in https://github.com/twilio/twilio-video.js/commit/e20d86e217b445fbc2c95cb511a0a8289ffa14ee should fix this.

As a workaround for now, you can call

room.localParticipant.tracks.forEach(track => track.stop());
Was this page helpful?
0 / 5 - 0 ratings