Enable rear camera with HTML5



To enable rear camera, firstly use −

MediaStreamTrack.getSources(gotSources);

Now, select the source and pass it in as optional into getUserMedia method.

This method is useful for users to set permission to use up to one video input device −

var a = {
   audio: {
      optional: [{sourceId: audioSource}]
   },
   video: {
      optional: [{sourceId: videoSource}]
   }
};
navigator.getUserMedia(a, successCallback, errorCallback);
Updated on: 2020-06-25T06:23:01+05:30

289 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements