mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Closes #167; Removed dependency on webrtc-adapter; Removed workaround for facing-mode that is not needed any more when using the latest version of webrtc-adapter;
This commit is contained in:
@@ -67,10 +67,11 @@ hostnames need to be served via `https://`. You can find more information in the
|
||||
|
||||
### Feature-detection of getUserMedia
|
||||
|
||||
QuaggaJS has a hard dependency on
|
||||
[webrtc-adapter](https://github.com/webrtc/adapter) which makes access to
|
||||
`getUserMedia` consistent throughout all browsers. Use this to test your
|
||||
browser's capabilities:
|
||||
Every browser seems to differently implement the `mediaDevices.getUserMedia`
|
||||
API. Therefore it's highly recommended to include
|
||||
[webrtc-adapter](https://github.com/webrtc/adapter) in your project.
|
||||
|
||||
Here's how you can test your browser's capabilities:
|
||||
|
||||
```javascript
|
||||
if (navigator.mediaDevices && typeof navigator.mediaDevices.getUserMedia === 'function') {
|
||||
|
||||
Vendored
+1373
-5407
File diff suppressed because one or more lines are too long
Vendored
+1
-4
File diff suppressed because one or more lines are too long
@@ -101,6 +101,7 @@
|
||||
</footer>
|
||||
|
||||
<script src="vendor/jquery-1.9.0.min.js" type="text/javascript"></script>
|
||||
<script src="//webrtc.github.io/adapter/adapter-latest.js" type="text/javascript"></script>
|
||||
<script src="../dist/quagga.js" type="text/javascript"></script>
|
||||
<script src="live_w_locator.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
+1311
-5348
File diff suppressed because one or more lines are too long
+3
-4
@@ -60,8 +60,8 @@
|
||||
"phantomjs": "^1.9.18",
|
||||
"sinon": "^1.17.7",
|
||||
"sinon-chai": "^2.8.0",
|
||||
"webpack": "^2.2.0-rc.3",
|
||||
"webpack-sources": "^0.1.3"
|
||||
"webpack": "^2.2.1",
|
||||
"webpack-sources": "^0.1.4"
|
||||
},
|
||||
"directories": {
|
||||
"doc": "doc"
|
||||
@@ -108,7 +108,6 @@
|
||||
"gl-vec3": "^1.0.3",
|
||||
"lodash": "^4.17.4",
|
||||
"ndarray": "^1.0.18",
|
||||
"ndarray-linear-interpolate": "^1.0.0",
|
||||
"webrtc-adapter": "^2.0.2"
|
||||
"ndarray-linear-interpolate": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,42 +69,15 @@ function deprecatedConstraints(videoConstraints) {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function pickDevice(constraints) {
|
||||
const desiredFacing = constraints.video.facingMode,
|
||||
facingMatch = facingMatching[desiredFacing];
|
||||
|
||||
if (!facingMatch) {
|
||||
return Promise.resolve(constraints);
|
||||
}
|
||||
return enumerateDevices()
|
||||
.then(devices => {
|
||||
const selectedDeviceId = devices
|
||||
.filter(device => device.kind === 'videoinput' && facingMatch.test(device.label))
|
||||
.map(facingDevice => facingDevice.deviceId)[0];
|
||||
if (selectedDeviceId) {
|
||||
constraints = {
|
||||
...constraints,
|
||||
video: {
|
||||
...omit(constraints.video, ["facingMode"]),
|
||||
deviceId: selectedDeviceId,
|
||||
}
|
||||
};
|
||||
}
|
||||
return Promise.resolve(constraints);
|
||||
});
|
||||
}
|
||||
|
||||
export function pickConstraints(videoConstraints) {
|
||||
const normalizedConstraints = {
|
||||
audio: false,
|
||||
video: deprecatedConstraints(videoConstraints)
|
||||
};
|
||||
|
||||
if (!normalizedConstraints.video.deviceId) {
|
||||
if (typeof normalizedConstraints.video.facingMode === 'string'
|
||||
&& normalizedConstraints.video.facingMode.length > 0) {
|
||||
return pickDevice(normalizedConstraints);
|
||||
}
|
||||
if (normalizedConstraints.video.deviceId
|
||||
&& normalizedConstraints.video.facingMode) {
|
||||
delete normalizedConstraints.video.facingMode;
|
||||
}
|
||||
return Promise.resolve(normalizedConstraints);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import TypeDefs from './common/typedefs'; // eslint-disable-line no-unused-vars
|
||||
import WebrtcAdapter from 'webrtc-adapter'; // eslint-disable-line no-unused-vars
|
||||
import ImageWrapper from './common/image_wrapper';
|
||||
import BarcodeLocator from './locator/barcode_locator';
|
||||
import BarcodeDecoder from './decoder/barcode_decoder';
|
||||
|
||||
Reference in New Issue
Block a user