added new restriction and fixed button dowload
This commit is contained in:
@@ -19,7 +19,6 @@ export default function BarcodeScanner({ onScan }: BarcodeScannerProps) {
|
||||
let zxingReader: BrowserMultiFormatReader | null = null;
|
||||
let detector: any = null;
|
||||
|
||||
/** 🚀 Intentar usar BarcodeDetector API (moderno) */
|
||||
const startBarcodeDetector = async () => {
|
||||
const supported = "BarcodeDetector" in window;
|
||||
if (!supported) {
|
||||
@@ -100,13 +99,10 @@ export default function BarcodeScanner({ onScan }: BarcodeScannerProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔍 Intentar encontrar la cámara trasera
|
||||
const backCamera =
|
||||
devices.find((d) =>
|
||||
d.label.toLowerCase().includes("back")
|
||||
) || devices.find((d) =>
|
||||
d.label.toLowerCase().includes("rear")
|
||||
) || devices[devices.length - 1]; // fallback
|
||||
devices.find((d) => d.label.toLowerCase().includes("back")) ||
|
||||
devices.find((d) => d.label.toLowerCase().includes("rear")) ||
|
||||
devices[devices.length - 1];
|
||||
|
||||
const selectedDeviceId = backCamera.deviceId;
|
||||
|
||||
@@ -136,7 +132,6 @@ export default function BarcodeScanner({ onScan }: BarcodeScannerProps) {
|
||||
|
||||
startBarcodeDetector();
|
||||
|
||||
|
||||
return () => {
|
||||
if (animationFrame) cancelAnimationFrame(animationFrame);
|
||||
if (stream) stream.getTracks().forEach((t) => t.stop());
|
||||
|
||||
Reference in New Issue
Block a user