As soon as I try to switch my camera to deskop the audio track gets removed on the remote users side. Even when going back to video mode the audio track is gone.
I also tried to requested audio explicitly but it also looks like there is neither an error thrown (catch) nor the console log with new tracks i called. But the other participants receive the shared screen. I’m a bit out of ideas. I thought it muste be my state management or that I remove tracks forcefully but I removed all this kind of code already and still, screen gets shared but without audio.
my switchVideo method looks like this right now:
switchVideo() {
this.$store.dispatch(SET_VIDEO_MODE, !this.isVideo)
// Using this or not makes no difference and also no error is thrown:
/*if (this.localTracks[1] && this.localTracks[1].getType() === 'video') {
this.localTracks[1].dispose();
this.localTracks.pop()
}*/
JitsiMeetJS.createLocalTracks({
// I also tried requesting audio explicitly for screensharing:
devices: ['audio', this.isVideo ? 'video' : 'desktop'],
facingModel: 'user',
desktopSharingFrameRate: {min: 60, max: 120},
firePermissionPromptIsShownEvent: true,
resolution: 1080,
constraints: {
video: {
aspectRatio: 16 / 9,
height: {
ideal: 1080,
max: 1080,
min: 720
}
}
}
})
.then(tracks => {
// This console log is never triggered but the video gets replaced properly: (magic sh*t?)
console.log('[REPLACE_LOCAL_TRACK] switchVideo', tracks)
// this.$store.dispatch(REPLACE_LOCAL_TRACK, tracks[1])
tracks[0].addEventListener(
JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
() => console.log('[switchVideo] local track muted'));
tracks[0].addEventListener(
JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
() => {
console.log('[switchVideo] local track stopped')
// This is really required to get back to video mode if screen share was ended by browser button:
this.switchVideo()
}
);
// First I just added tracks[1] because I thought video is enough but even adding all tracks again does neither work, nor throw an error
tracks.forEach(track => {
this.jRoom.addTrack(track);
})
})
.catch(error => console.log(error));
},