webcam.js

How do I use the main camera (back Camera) in WebCam.js


I am using webcam.js by https://github.com/jhuckaby/webcamjs and In mobile devices, It's working well the front camera is opening by default. I can't change it to back Camera, I want to change the default to the Main camera.

Is there any way to change to the main camera device?


Solution

  • answer is so simple, just add this setting row to your page,

    constraints: { facingMode: 'environment' }
    

    it will be like this:

    Webcam.set({
     width: 640,
     height: 480, 
     image_format: 'jpeg',
     jpeg_quality: 800,
     constraints: { facingMode: 'environment' }
    });