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);
Samual Sam
Samual Sam

Learning faster. Every day.


Advertisements