Jitsi Meet API - Camera Switch

Hi, guys!

Is there any way on Jitsi Meet API to create an external button and trigger any event to switch between available cameras on a device? Anyone have implemented something like that before?

Thank you so much.

i did it like this

  const { JitsiMeetJS } = window;

  const videoContainer = document.querySelector('.js-self-video-container');
  const selfVideo = document.getElementById('self-video');
  const companionVideo = document.getElementById('companion-video');
  const companionAudio = document.getElementById('companion-audio');
  const cameraSwitchButton = document.getElementById('camera-switch-button');

  const options = {
    hosts: {
      domain: 'meet.jit.si',
      muc: 'conference.meet.jit.si',
      focus: 'focus.meet.jit.si',
    },
    bosh: `https://meet.jit.si/http-bind?room=${roomId}`,
    clientNode: 'http://jitsi.org/jitsimeet',
  };

  let room = null;
  let connection = null;
  let isJoined = false;

  let shouldFaceUser = true;
  let localTracks = [];
  const remoteTracks = {};

  const startConference = () => {
    room.join();
  };

  const stopVideoStream = () => {
    localTracks.forEach((track) => track.dispose());
  };

  const endConference = () => {
    stopVideoStream();
    room.leave();
    connection.disconnect();
  };

  const onLocalTracks = (tracks) => {
    localTracks = tracks;
    localTracks.forEach((track) => {
      if (track.getType() === 'video') {
        track.attach(selfVideo);
      }

      if (isJoined) {
        room.addTrack(track);
      }
    });
  };

  const onRemoteTrack = (track) => {
    if (track.isLocal()) return;

    const participant = track.getParticipantId();

    if (!remoteTracks[participant]) {
      remoteTracks[participant] = [];
    }

    remoteTracks[participant].push(track);

    if (track.getType() === 'video') {
      track.attach(companionVideo);
    } else {
      track.attach(companionAudio);
    }
  };

  const onConferenceJoined = () => {
    isJoined = true;
    localTracks.forEach((track) => room.addTrack(track));
  };

  const onUserLeft = (id) => {
    if (!remoteTracks[id]) return;

    const tracks = remoteTracks[id];

    tracks.forEach((track) => track.detach());
  };

  const onConnectionSuccess = () => {
    room = connection.initJitsiConference(roomId, { openBridgeChannel: false });
  };

  const getStream = () => {
    JitsiMeetJS.createLocalTracks({
      devices: ['audio', 'video'],
      facingMode: shouldFaceUser ? 'user' : 'environment',
    })
      .then(onLocalTracks)
  };

  JitsiMeetJS.init({ disableAudioLevels: true });

  connection = new JitsiMeetJS.JitsiConnection(null, null, options);

  connection.connect();

  getStream();

  cameraSwitchButton.addEventListener('click', () => {
    shouldFaceUser = !shouldFaceUser;

    stopVideoStream();
    getStream();
  });
}