PiotrFLEURY / camcode

a Flutter web camera barcode scan library
https://camcode-59c70.web.app/#/
BSD 3-Clause "New" or "Revised" License
11 stars 11 forks source link

Trying to use back camera on Android device (Flutter Web app). fetchDeviceList never completes #23

Open MomijiMatt opened 2 years ago

MomijiMatt commented 2 years ago

I'm using an Android tablet running this as a Flutter web app. I'm using Quagga like the example. The barcode.js code looks like this:

function detectBarcode(dataUrl, callback) {
    Quagga.decodeSingle({
        decoder: {
            readers: [
                "code_128_reader",
                "ean_reader",
                "ean_8_reader",
                "code_39_reader",
                "code_39_vin_reader",
                "code_93_reader"
            ] // List of active readers
        },
        locate: true, // try to locate the barcode in the image
        src: dataUrl // or 'data:image/jpg;base64,' + data
    }, function (result) {
        if (result && result.codeResult) {
            console.log("result", result.codeResult.code);
            callback(result.codeResult.code);
        } else {
            console.log("not detected");
        }
    });
}

After some research I thought maybe I could use the CamCodeScannerController.selectDevice() function to set it to the back camera. So I tried to use CamCodeScannerController.fetchDeviceList(), but that never completes when I call it (i.e. if I do await CamCodeScannerController.fetchDeviceList() it never gets past that line).

At this point I'm not even sure if I'm supposed to be setting the device in the Quagga code or in the CamCodeScannerController.

So to reiterate: The end goal is to get it to use the back camera instead of the front camera.

PiotrFLEURY commented 2 years ago

Hi @MomijiMatt

Thank you for your feedback.

Unfortunately, I do not have enough time to maintain this package on my own.

By default, camcode should select the back camera.

As far I can remember, camera selection was working well on several devices. But on devices that have multiple back camera I encountered troubles.

I have no physical tablet so I cannot test this use case.

I'll see if I can try to fix this, but if you have time, feel free to make pull request.