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

Device label (human-readable name for the camera device) is empty string in android app webview #57

Open
aminurrashid opened this issue Jun 10, 2020 · 3 comments

Comments

@aminurrashid
Copy link

aminurrashid commented Jun 10, 2020

Describe the bug
I'm developing an android app, which has a webview in it. When loading the qr scanning demo page (https://blog.minhazav.dev/research/html5-qrcode.html) or a page that implemented the html5-qrcode library, device label (human-readable name for the camera device) is empty string.

sample:
id: "4c2c562185edeff69ceb28984aec24160b359fc3567422065818a41e4070f60c"
label: ""

To Reproduce
Steps to reproduce the behavior:

  1. Load https://blog.minhazav.dev/research/html5-qrcode.html in android webview
  2. Click "Select Camera" drop down list.

Expected behavior
Device names (camera) should be shown in drop down list.

Smartphone

  • Device: Nexus 6P
  • OS: android 8.1.0
@sensationpanda
Copy link

the same problem, some Android phone has many cameras

@mebjas
Copy link
Owner

mebjas commented Oct 3, 2020

@sensationpanda There is a way to handle this if you want to build for smartphones - with latest version you can use the facing mode instead of the cameraId + label

const html5QrCode = new Html5Qrcode("#reader");
const qrCodeSuccessCallback = message => { /* handle success */ }
const config = { fps: 10, qrbox: 250 };

// If you want to prefer front camera
html5QrCode.start({ facingMode: "user" }, config, qrCodeSuccessCallback);

// If you want to prefer back camera
html5QrCode.start({ facingMode: "environment" }, config, qrCodeSuccessCallback);

// Select front camera or fail with `OverconstrainedError`.
html5QrCode.start({ facingMode: { exact: "user"} }, config, qrCodeSuccessCallback);

// Select back camera or fail with `OverconstrainedError`.
html5QrCode.start({ facingMode: { exact: "environment"} }, config, qrCodeSuccessCallback);

This is a demo for that - https://blog.minhazav.dev/research/h5q-direct, this might be helpful for the webview related issue as well. Can you check if this helps?

@mebjas
Copy link
Owner

mebjas commented Oct 3, 2020

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

No branches or pull requests

3 participants