Screenshare is not working for the second time when multi-stream mode is enabled

First-time screen share is working fine but when the user tries to share the screen again the screen share is not working.

not able to get the new track on room.on(JitsiMeetJS.events.conference.TRACK_ADDED, () => {console.log('New Track')});

const desktopLocalTrack = await JitsiMeetJS.createLocalTracks({devices: ['desktop']});
if (this.desktopTrackLocal) {
    this.isLocalScreenShared = true;
     await this.room.addTrack(this.desktopTrackLocal);
}

I’m using .mute() method to stop the screen share

if (desktopTrackLocal) {
  await this.desktopTrackLocal.mute();
 }

note: multi-stream mode is enabled

Ping @jallamsetty

1 Like

able to fix the issue by adding JitsiMeetJS.events.track.TRACK_MUTE_CHANGED listener on the receiver side.

Yes, thats the right approach. Screenshare needs to be treated like a camera stream in multi-stream mde. When the SS track is added to the conference for the first time, addTrack() needs to be called, mute for stopping the share and for restarting, the original jitsiLocalTrack needs to be replaced with the new desktop track. On the receiver side, a listener needs to be added for TRACK_MUTE_CHANGED event to determine when the SS track is available to be rendered.

1 Like

Thank you @jallamsetty @saghul

1 Like