Enable rear camera with HTML5

Check out https://simpl.info/getusermedia/sources/ that shows how you can select sources using

MediaStreamTrack.getSources(gotSources);

You can then select the source and pass it in as optional into getUserMedia

var constraints = {
  audio: {
    optional: [{sourceId: audioSource}]
  },
  video: {
    optional: [{sourceId: videoSource}]
  }
};
navigator.getUserMedia(constraints, successCallback, errorCallback);

It is now fully available in Stable Chrome and mobile (As of v30)

Leave a Comment