Twilio-video.js: Unable to switch to rear camera on iOS mobile safari

Created on 20 Nov 2017  路  3Comments  路  Source: twilio/twilio-video.js

I am currently using twilio_video.js V 1.6.0 for mobile safari. I am able to render the video using the front camera but unable to make it works on the rear camera using the following codes:

publisherElem = document.getElementById('mobile-publisher')
video = publisherElem.querySelector('video')
Twilio.Video.createLocalVideoTrack(
  deviceId: source.deviceID
).then (localTrack) ->
  localTrack.attach video
  return

here is the screenshot

screen shot 2017-11-20 at 11 37 07 am

iOS question

Most helpful comment

Just a friendly heads up - the non-user camera constraint should be

Twilio.Video.createLocalVideoTrack({
  facingMode: "environment"
});

instead of

Twilio.Video.createLocalVideoTrack({
  facingMode: "rear"
});

Source: https://www.w3.org/TR/mediacapture-streams/#def-constraint-facingMode

All 3 comments

Hi @vsrboth,

Can you please try specifying the facingMode constraint? It can have one of two values, e.g.

  • "user", or
  • "rear".

You can use it as follows in your code snippet:

Twilio.Video.createLocalVideoTrack({
  facingMode: "rear" // or "user"
});

There was some similar discussion for the LG G5 SE here.

Best,
Mark

Just a friendly heads up - the non-user camera constraint should be

Twilio.Video.createLocalVideoTrack({
  facingMode: "environment"
});

instead of

Twilio.Video.createLocalVideoTrack({
  facingMode: "rear"
});

Source: https://www.w3.org/TR/mediacapture-streams/#def-constraint-facingMode

I think this question is answered, as far as constraints go. For anyone struggling with switching between front and back cameras, though, please be aware of this issue and the associated WebKit Bug 188606.

Best,
Mark

Was this page helpful?
0 / 5 - 0 ratings