Tastenkunst / brfv4_javascript_examples

BRFv4 - HTML5/Javascript - examples project. Reference implementation for all other platform example packages.
463 stars 148 forks source link

open rear camera in mobile #6

Closed AlaaElZein closed 7 years ago

AlaaElZein commented 7 years ago

Hello, Can we open the rear camera in mobile in brfv4? Regards,

MarcelKlammer commented 7 years ago

Mobile mean iOS 11? found this: http://robporter.ca/safari-11/

AlaaElZein commented 7 years ago

no i am working on chrome on android, and the code works correctly in brfv4 but the mobile camera (samsung chrome) is opened as front cam. i need to open the rear cam in the code on brfv4

MarcelKlammer commented 7 years ago

So you already tried

"facingMode": "environment"

for the camera constraint?

AlaaElZein commented 7 years ago

where should i add this variable? i searched in all the downloaded brfv4 project and there is no existed variable called facing mode in the js.

MarcelKlammer commented 7 years ago

It's a webcam constraint.

In this file:

https://github.com/Tastenkunst/brfv4_javascript_examples/blob/master/js/utils/BRFv4SetupWebcam.js

line 28:

webcam.constraints = {video: {width: width, height: height, frameRate: fps}};

should be:

webcam.constraints = {video: {width: width, height: height, frameRate: fps, facingMode: "environment"}};

AlaaElZein commented 7 years ago

okayy it works fine now thank you very much

MarcelKlammer commented 7 years ago

np

ghandic commented 6 years ago

Hi, can easily this be dynamically changed? so the user can choose their camera?

MarcelKlammer commented 6 years ago

Look into facingMode. Set the desired facingMode the first time and then have a toggle button that switches between environment and user.

https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/facingMode