Skip to content

fix getCameras not work #502

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

Merged
merged 1 commit into from
Jul 8, 2022
Merged

fix getCameras not work #502

merged 1 commit into from
Jul 8, 2022

Conversation

Jerry-qiqi
Copy link
Contributor

navigator.mediaDevice.getUserMedia maybe is undefined

@mebjas
Copy link
Owner

mebjas commented Jul 8, 2022

thanks for the change.

@mebjas mebjas merged commit 8bcdbc0 into mebjas:master Jul 8, 2022
@rlueder
Copy link
Contributor

rlueder commented Aug 9, 2022

I'm getting an error when running npm run-script build on 2.2.1 which seems related to this change, output below:

src/html5-qrcode.ts:735:39 - error TS2774: This condition will always return true since this function is always defined.
Did you mean to call it instead?

735         if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error.

The check itself is valid as it's used again on line 398 but TypeScript doesn't seem to like the fact we're checking for getUserMedia and not actually using it, a simple fix is to just add // @ts-ignore to the line just above it:

// @ts-ignore
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  return Html5Qrcode.getCamerasFromMediaDevices();
}

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

Successfully merging this pull request may close these issues.

3 participants