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

it's not possible to set some of the constraints #24

Closed
nomaddan opened this issue Feb 15, 2024 · 2 comments
Closed

it's not possible to set some of the constraints #24

nomaddan opened this issue Feb 15, 2024 · 2 comments
Labels

Comments

@nomaddan
Copy link

nomaddan commented Feb 15, 2024

I encountered an issue with certain Samsung devices (e.g. S22) where the camera fails to focus properly, resulting in blurry QR codes that cannot be scanned. Upon researching potential solutions on the internet, it appears that setting the auto-focus constraint focusMode: continuous may resolve the issue. Here's an example of how I try to use the constraints:

constraints={{
  facingMode: 'environment',
  focusMode: 'continuous',
}}

However, when attempting to set the focusMode property, I encountered the following error:

Type '{ facingMode: string; focusMode: string; }' is not assignable to type 'MediaTrackConstraints'.
  Object literal may only specify known properties, and 'focusMode' does not exist in type 'MediaTrackConstraints'.

Upon inspecting the library source code, I observed that the constraints prop is passed to the Finder component and utilized in the useMediaDevices hook, as seen here: useMediaDevices.ts.

Additionally, I noticed that there is an open issue (#22) on the repository regarding similar zoom constraint problem.

It seems logical to me that it should be possible to pass constraints such as focusMode or zoom to window.navigator.mediaDevices, especially when browser console output from navigator.mediaDevices.getSupportedConstraints() clearly states that those constraints do exist in the browser API.

Sources:
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#focusmode

https://forum.developer.samsung.com/t/camera-auto-focus-and-zoom-camera-not-working-in-the-web-application/27908/1

mebjas/html5-qrcode#308

Besides that, it is a great library and works flawlessly on apple devices without any problems.

Kindly requesting @yudielcurbelo for any assistance or suggestions on how to address these issues.

@davidjandrey-sv
Copy link

I'm facing the same issue with focusMode apparently not being a property anymore. However the Scanner works flawlessly on Android phones for me (default config), and not at all on iPhones. Since you said that it works flawlessly on Apple devices, would you mind sharing your config? 😅

Copy link

stale bot commented Apr 7, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 7, 2024
@stale stale bot closed this as completed Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants