From b09ded15a882a4b114da88b06a547015f74be496 Mon Sep 17 00:00:00 2001 From: Niklas Gruhn Date: Fri, 12 Jun 2020 13:41:25 +0200 Subject: [PATCH] fix: narrow down camera selection Modern phones often have multipe front/rear cameras. Sometimes special purpose cameras like the wide-angle camera are picked by default. Those are not optimal for scanning QR codes but standard media constraints don't allow us to specify which camera we want exactly. However, we can obtain a list of all video input devices with navigator.mediaDevices.enumerateDevices() Picking the first entry as the default front camera and the last entry as the default rear camera seems to be a valid heuristic. Issue: #179 --- demo.html | 6 ++-- src/components/QrcodeStream.vue | 43 +++--------------------- src/misc/camera.js | 59 ++++++++++++++++++++++++++++++--- 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/demo.html b/demo.html index 16249c51..03f5164a 100644 --- a/demo.html +++ b/demo.html @@ -8,8 +8,8 @@ - - + +