How the Barcode Reader Decodes
AnyTool Barcode Reader works two ways, both entirely in the browser. For live scanning it calls navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } }) to open a back-facing camera into a muted, playsInline video element. Where the native Barcode Detection API is present (Chromium-based browsers and Android) it creates a BarcodeDetector configured for many formats and runs a requestAnimationFrame loop that draws each frame to an offscreen canvas and calls detector.detect(canvas); where it is not (notably Firefox and Safari) it lazily imports @zxing/browser and uses BrowserMultiFormatReader.decodeFromVideoDevice(deviceId, video, callback), which owns the stream and reports each hit with result.getText() and result.getBarcodeFormat(). For image decoding it draws a dropped, pasted or uploaded picture to a canvas and decodes it once with the same native-first, ZXing-fallback path (BrowserMultiFormatReader.decodeFromImageElement). ZXing is lazily imported into its own chunk so it is never part of the app shell, and on a hit the tool optionally plays a short WebAudio beep.
- Camera: getUserMedia → native BarcodeDetector rAF loop, or ZXing decodeFromVideoDevice
- Image: dropped, pasted or uploaded picture decoded once on a canvas / image element
- Native BarcodeDetector (Chromium / Android) with an @zxing/browser fallback everywhere
- ZXing is lazily imported into its own chunk, so it is not in the app shell
- Reads 1D (EAN, UPC, Code 128/39/93, Codabar, ITF) and 2D (QR, Data Matrix, Aztec, PDF417)
