-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: merge master into vue3-compatibility (#314)
* fix(QrcodeStream): iOS 15 won't render camera When a camera stream is loaded, we assign the stream to a `video` element via `video.srcObject`. At this point the element is hidden with `v-show="false"` aka. `display: none`. We do that because at this point the videos dimensions are not known yet. We have to wait for the `loadeddata` event first. Only after that event we display the video element. Otherwise the elements size awkwardly flickers. However, it appears since iOS 15 all iOS browsers won't properly render the video element if the `video.srcObject` was assigned *while* the element was hidden with `display: none`. Using `visibility: hidden` instead seems to have fixed the problem though. Issue: #264 #266 * fix(QrcodeStream): black list cameras by label Modern devices sometimes have multiple rear cameras. Not all are optimal for scanning QR codes. For example wide angle, infra-red and virtual cameras. By maintaining a black list of unsuitable cameras with unique labels we can gradually exlude more and more of them. Issue: #269 #253 * fix(QrcodeStream): reject infrared cameras When automatically selecting a camera we want to avoid infrared cameras since they are not suitable for scanning QR codes. Some infrared camera labels have the substring "infrared". So we filter by that. Issue: #269 * docs: update Upload demo On supporting mobile devices QrcodeCapture does not open the file dialog by default but starts the camera instead. This is supposed to be a feature but developers keep being surprised by it or think it's a bug. Therefore trying to clarify this in the associated demo. Issue: #167 #211 #232 #272 #278 * feat(ts): specify types in package * Remove unused obsolete import DropImageDecodeError was removed in dea620e Co-authored-by: Niklas Gruhn <niklas@gruhn.me> Co-authored-by: RobWalker <rob.walker@auctria.com>
- Loading branch information
1 parent
495cc3a
commit 4b8ed6d
Showing
8 changed files
with
165 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: Wrong camera selected | ||
about: | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
If your device defaults to the wrong camera, please [open this demo](https://gruhn.github.io/vue-qrcode-reader/select-camera-demo.html). | ||
You should see a list of all cameras installed on your device. | ||
Copy the list and mark the camera that was picked by default and the camera that should actually be picked. | ||
For example like this: | ||
|
||
``` | ||
FaceTime HD Camera (Built-in) [DEFAULT] | ||
A different Camera [PREFERRED] | ||
Another different Camera | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<script src="https://cdn.jsdelivr.net/npm/webrtc-adapter@7.6.1/out/adapter.js"></script> | ||
</head> | ||
<body> | ||
cameras: <br> | ||
<ul></ul> | ||
<br> | ||
<video autoplay muted playsinline></video> | ||
|
||
<script> | ||
const listEl = document.querySelector("ul") | ||
|
||
const renderOptions = (currentDeviceId, devices) => { | ||
listEl.innerHTML = "" | ||
|
||
devices | ||
.filter(deviceInfo => deviceInfo.kind === "videoinput") | ||
.map(({ label, deviceId }) => { | ||
const el = document.createElement('li') | ||
|
||
if (deviceId == currentDeviceId) | ||
el.innerHTML = `<a href="#" onclick="selectCamera('${deviceId}')">${label}</a> [PREFERRED]` | ||
else | ||
el.innerHTML = `<a href="#" onclick="selectCamera('${deviceId}')">${label}</a>` | ||
|
||
return el | ||
}) | ||
.forEach(el => listEl.appendChild(el)) | ||
} | ||
|
||
|
||
let stream | ||
|
||
const selectCamera = async deviceId => { | ||
try { | ||
console.log(deviceId) | ||
|
||
if (stream) { | ||
stream.getTracks().forEach(track => track.stop()) | ||
} | ||
|
||
const videoConstraints = {}; | ||
if (!deviceId) { | ||
videoConstraints.facingMode = 'environment'; | ||
} else { | ||
videoConstraints.deviceId = { exact: deviceId }; | ||
} | ||
|
||
stream = await navigator.mediaDevices.getUserMedia({ | ||
audio: false, | ||
video: videoConstraints, | ||
}) | ||
|
||
const videoEl = document.querySelector('video') | ||
videoEl.srcObject = stream | ||
|
||
const [ videoTrack ] = stream.getVideoTracks() | ||
|
||
renderOptions( | ||
videoTrack.getSettings().deviceId, | ||
await navigator.mediaDevices.enumerateDevices() | ||
) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
|
||
selectCamera() | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters