Skip to content

V1.2.1

Compare
Choose a tag to compare
@mebjas mebjas released this 30 Aug 10:08
· 180 commits to master since this release
e01c690

Added support for facingMode constraing in Html5Qrcode#start

Update:
In mobile devices you may want users to directly scan the QR code using the back camera or the front camera for some use cases. For such cases you can avoid using the exact camera device id that you get from Html5Qrcode.getCameras(). The start() method allows passing constraints in place of camera device id similar to html5 web API syntax. You can start scanning like mentioned in these examples:

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);