twiliotwilio-click-to-calltwilio-video

Twilio programmable video using back camera of phone in selected devices?


When I configured Twilio programmable video using following code:

Video.connect(token, {
      name: roomName,
      audio: true,
      logLevel: 'info',
      maxAudioBitrate: 16000,
      video: { frameRate: 30, width: 1260, height: 650, controls: false },
    })

In some of the devices such as Ipad tab or mobile phones, user is connecting to back camera instead of front camera of device.

Is there a way for us to specify the constraints to make sure Twilio video is always connecting to only front camera. Thanks!


Solution

  • Twilio developer evangelist here.

    I wrote about how to select cameras in JavaScript here. If you are trying to ensure you select a user facing camera, then you want the facingMode constraint. Set facingMode to user and you will select user facing cameras on a system that supports it.

    Video.connect(token, {
          name: roomName,
          audio: true,
          logLevel: 'info',
          maxAudioBitrate: 16000,
          video: {
            frameRate: 30,
            width: 1260,
            height: 650,
            facingMode: "user"
          },
        });
    

    Note that I don't believe controls is a valid media constraint, so I have removed that from the code above.