标签: zxing-js

如何在 JS 中使用 ZXing 从网络摄像头扫描二维码?

我无法按照主存储库上的自述文件示例来设置库。我不想使用 ES6、AMD 或任何需要构建步骤的方法。

javascript zxing zxing-js

3
推荐指数
1
解决办法
1万
查看次数

ZXing 强制 Android 设备上的后置摄像头?

我正在构建一个使用 ZXing 库扫描条形码的项目。目前,我的代码适用于 iOS 设备,打开后置摄像头,但在使用 Android 设备进行测试时,它会打开前置摄像头。有没有办法让我始终强制在任何设备上使用后置摄像头?请参阅下面的工作代码:

    <script type="text/javascript">
        window.addEventListener('load', function () {
            let selectedDeviceId;
            const codeReader = new ZXing.BrowserMultiFormatReader();
            console.log('ZXing code reader initialized');
            codeReader.getVideoInputDevices()
                .then((videoInputDevices) => {
                    if (videoInputDevices.length < 1) {
                        console.log('No video devices found');
                        return;
                    }

                    selectedDeviceId = videoInputDevices[0].deviceId;

                    codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) => {
                        if (result) {
                            console.log(result);
                            var barcode = result;
                            //this.window.alert(barcode);
                            if (String(barcode).charAt(0) == 'L') {
                                document.getElementById('result').textContent = result.text;
                                document.getElementById('result').style.color = "green";
                                var previousurl = document.referrer;
                                window.location.href = previousurl + "&BarCode=" + result.text;
                            } …
Run Code Online (Sandbox Code Playgroud)

javascript android zxing android-camera zxing-js

3
推荐指数
1
解决办法
3673
查看次数

标签 统计

javascript ×2

zxing ×2

zxing-js ×2

android ×1

android-camera ×1