From a4498a18472073dd88b062079e0bfa0f0751ec11 Mon Sep 17 00:00:00 2001 From: Victor Winberg Date: Sun, 18 Aug 2024 17:43:55 +0200 Subject: [PATCH] fix(scanner): select correct camera --- client/src/components/QRScanner.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/components/QRScanner.vue b/client/src/components/QRScanner.vue index d2fa715d..d337a936 100644 --- a/client/src/components/QRScanner.vue +++ b/client/src/components/QRScanner.vue @@ -64,9 +64,11 @@ export default Vue.extend({ ...mapMutations("scan", ["stopScan"]), ...mapActions("scan", ["handleQR"]), async initScanner() { - const devices = await navigator.mediaDevices.enumerateDevices(); - const cameras = devices.filter(device => device.kind === "videoinput"); - const camera = cameras[cameras.length - 1]; + await navigator.mediaDevices.getUserMedia({ + video: { facingMode: "environment" } + }); + const cameras = await navigator.mediaDevices.enumerateDevices(); + const camera = cameras[0]; const { qrscan } = this.$refs; if (!camera || !qrscan) return;