juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
804 stars 471 forks source link

Can't get it to work on the web #1084

Open jankeso opened 2 months ago

jankeso commented 2 months ago

I'm using version 5.1.1, the browser is most recent Chrome on Windows 10. I tried a simple approach with onDetect in MobileScanner and the controller. Here's the widget code for simple onDetect version:

` class BarcodeScanner extends StatefulWidget { const BarcodeScanner({super.key});

@override _BarcodeScannerState createState() => _BarcodeScannerState(); }

class _BarcodeScannerState extends State with WidgetsBindingObserver {

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: const Icon(Icons.arrow_back), onPressed: () => Navigator.of(context).pop(), ), title: const Text('Scan a code'), ), body: SafeArea( child: Stack( children: [ MobileScanner( onDetect: _handleBarcode, errorBuilder: (context, error, child) { return ScannerErrorWidget(error: error); }, ), ], ), ), ); }

void _handleBarcode(BarcodeCapture barcode) { print("scanned barcode"); print(barcode.barcodes); } } `

This is what I get in the console for both onDetect and controller: scanned barcode [] Trying to play video that is already playing.

What am I missing?

navaronbracke commented 2 months ago

The Trying to play video that is already playing. message is a log from ZXing and should be harmless (it calls play() on the HTMLVideoElement, which was already playing)

Could you provide a sample of the barcode that you are trying to scan?

zamanzamzz commented 2 months ago

I am having a the same issue as well. I am not able to get any barcodes to scan on the web.

Here is a sample of one:

image

Shonu72 commented 1 month ago

I was having same problem then i chnaged to version 4.0.1 and now it's working on web

zamanzamzz commented 3 weeks ago

I was having same problem then i chnaged to version 4.0.1 and now it's working on web

I tried this myself after you posted and I'm seeing the same behaviour as well. It seems like the update to version 5.0 broke web functionality.