How can I change the input device using low-level API?

Hello everybody,

I am now looking for days for a solution and I hope I will find it here. I am currently working on a different UI for a Jitsi session and I want to give the participant the option to change the input device. But I cannot find anything in this regard in the documentation or anywhere. I am working with the Jitsi low-level API.

Thanks for any help provided in advance.

Because I found a lot of topics about this topic but never anyone posted an answer I thought I add this here so people who see this thread will find the solution.

In order to change an input device you need to replace the track with the current track. This is done by using the replaceTrack(oldtrack, newtrack) function of your conference object. If you want to use on a change-eventlistener it would look something like this:

changeInputVideo(event) {
    const cameraDeviceId = event.target.value; // value => deviceid
    const currentLocalVideoTrack = this.localTracks.find(track => track.type === 'video'); // store your local tracks somewhere. In my case this is inside a class 
    JitsiMeetJS.createLocalTracks({ // create a new track for the new device id
        devices: ['video'],
        cameraDeviceId,
    }).then(([track]) => { // when you have a new track 
        this.localTracks.push(track);
        this.room.replaceTrack(currentLocalVideoTrack, track);
        track.attach(this.videoNode); // attach the track to your video node.
    });
},

This is the same for audio inputs but different when you want to change the output:

changeOutputAudio(event) 
    JitsiMeetJS.mediaDevices.setAudioOutputDevice(event.target.value); // event.target.value === deviceid
},