Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set default camera to rear camera #59

Closed
sinh-idnow opened this issue Aug 7, 2019 · 2 comments
Closed

Can't set default camera to rear camera #59

sinh-idnow opened this issue Aug 7, 2019 · 2 comments

Comments

@sinh-idnow
Copy link

I want to set rear camera as default camera when user access my web via their phone. I try to set facingMode in videoOption, follow description from this page:

public videoOptions: MediaTrackConstraints = {
    facingMode: 'environment'
  };
 <webcam height="480" resizeMode="crop-and-scale" ....
      [videoOptions]="videoOptions" [imageQuality]="0.7"
          ....>
  </webcam>

But there are nothing happen :(. Now, I try to switch camera base on MediaDeviceInfo.label but this is not good solution because we should not base on label rule (have front or back word inside label)

My question is: do we have any official way to get rear camera? I think this requirement every popular for mobile webapp

Thank you for supporting

@basst314
Copy link
Owner

basst314 commented Aug 9, 2019

Hi @sinh-idnow,

Thanks for raising this.
You‘re right, currently the only way to pass in your requirements is to pass in MediaTrackConstraints through videoOptions.

Instead of specifying facingMode:‘environment‘, have you tried using the more advanced properties of ConstraintDOMString?

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

Can you try using the ‚ideal‘ property of it?

Also what browser are you using? Are you trying it on a laptop/desktop/phone? What exactly is the result you‘re seeing?

Please provide some details so that I can try to reproduce the issue.

Thanks!

@basst314
Copy link
Owner

Hi @sinh-idnow,

I was able to reproduce the issue. I fixed a glitch where user provided video constraints were not applied properly under some circumstances. The issue appeared just on some devices and had to do with the amount of information the respective device/browser revealed about the available webcams.
Fixed in version 0.2.6 of this library.

I was able to control the facingMode with the property you described. However I didn't use facingMode: 'environment' directly in my tests, but facingMode: { ideal: 'environment' } (see this).

In case you still encounter any issues, feel free to open a new issue here.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants