【问题标题】:Select back camera on html5-qrcode.min.js在 html5-qrcode.min.js 上选择后置摄像头
【发布时间】:2021-08-17 06:45:22
【问题描述】:

我使用这个二维码扫描器: https://github.com/mebjas/html5-qrcode

我用这个码扫描二维码:

         function onScanSuccess(decodedText, decodedResult) {
  // handle the scanned code as you like, for example:
  document.getElementById('text').value = decodedText;
  console.log(`Code matched = ${decodedText}`, decodedResult);
}

function onScanFailure(error) {
  // handle scan failure, usually better to ignore and keep scanning.
  // for example:
  console.warn(`Code scan error = ${error}`);
}

let html5QrcodeScanner = new Html5QrcodeScanner(
    "reader", { fps: 10, qrbox: 250 }, /* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess, onScanFailure);

可以将默认摄像头设置为后置 smartfone 摄像头。我想在启动时运行带有后置摄像头的扫描仪。 谢谢,请帮忙。

【问题讨论】:

标签: javascript html qr-code


【解决方案1】:

我在启动扫描仪时使用这段代码完成它:

面临模式:{精确:“环境”}

也许这会帮助您指明正确的方向。以下是我启动扫描仪时使用该设置的方式:

    /** load scanner using back camera **/
    html5QrCode.start({ facingMode: { exact: "environment"} }, config, qrCodeSuccessCallback);

【讨论】:

  • (这里是代码作者)@Rodney 的答案是正确的。
猜你喜欢
  • 2017-06-03
  • 1970-01-01
  • 2023-03-27
  • 2015-10-29
  • 1970-01-01
  • 2020-04-25
  • 1970-01-01
  • 2020-09-20
相关资源
最近更新 更多