How i can use my back camera of my phone in the browser with QUAGGA JS

883 Views Asked by At

i want to use Quagga js in my webapp to scan a barcodes... The problem is that i want use the mobile's back camera, in the documentation say's that quagga use a parameter called "facingMode". If you set facingMode = "enviroment" that use the webcam if you stay in a PC or the back camera if you stay in a Phone . And if you set facingMode = "user" that use the mobile's front camera. Well, i set user and enviroment for test and there is no difference, it stays the same, on the cell phone continues to use the front camera, i try to use the back camera but nothing. I leave my code at there

function startScanner() {
            Quagga.init({
                inputStream: {
                    name: "Live",
                    type: "LiveStream",
                    target: document.querySelector('#scanner-container'),
                    constraints: {
                        width: 600,
                        height: 450,
                        facingMode: "enviroment" //or user for front camera
                    },
                },
                decoder: {
                    readers: [
                        "code_128_reader",
                        "ean_reader",
                        "ean_8_reader",
                        "code_39_reader",
                        "code_39_vin_reader",
                        "codabar_reader",
                        "upc_reader",
                        "upc_e_reader",
                        "i2of5_reader"
                    ],
                    debug: {
                        showCanvas: true,
                        showPatches: true,
                        showFoundPatches: true,
                        showSkeleton: true,
                        showLabels: true,
                        showPatchLabels: true,
                        showRemainingPatchLabels: true,
                        boxFromPatches: {
                            showTransformed: true,
                            showTransformedBox: true,
                            showBB: true
                        }
                    }
                },

            }, function (err) {
                if (err) {
                    console.log(err);
                    return
                }

                console.log("Initialization finished. Ready to start");
                console.log(navigator.mediaDevices.enumerateDevices());
                Quagga.start();

                // Set flag to is running
                _scannerIsRunning = true;
            });

i tried in Android Phone

0

There are 0 best solutions below