replaceTrack does not show new track

Hello,

i am trying to change a video/camera track with a video/desktop track, but it is doing nothing. I provided you an example via github (ignore the strophe errors in console).

github: GitHub - xXTraceXx/Replace_Track

Maybe someone has an idea, what i am doing wrong. Thanks in advance!

Update:

i got it to work with adding an event-handler (“track_added”) and attaching the track:

room.on(JitsiMeetJS.events.conference.TRACK_ADDED, (track) => {

   console.log('new track added...');
   track.attach($('#localVideo')[0]);
   console.log(track);
  });

I am not 100% sure if that is the way to go^^ but i works