Skip to content

Commit

Permalink
fix(scanner): select correct camera
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorWinberg committed Aug 18, 2024
1 parent 5ee9ce4 commit a4498a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/src/components/QRScanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a4498a1

Please sign in to comment.