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
|
### Feature-detection of getUserMedia
|
||||||
|
|
||||||
QuaggaJS has a hard dependency on
|
Every browser seems to differently implement the `mediaDevices.getUserMedia`
|
||||||
[webrtc-adapter](https://github.com/webrtc/adapter) which makes access to
|
API. Therefore it's highly recommended to include
|
||||||
`getUserMedia` consistent throughout all browsers. Use this to test your
|
[webrtc-adapter](https://github.com/webrtc/adapter) in your project.
|
||||||
browser's capabilities:
|
|
||||||
|
Here's how you can test your browser's capabilities:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
if (navigator.mediaDevices && typeof navigator.mediaDevices.getUserMedia === 'function') {
|
if (navigator.mediaDevices && typeof navigator.mediaDevices.getUserMedia === 'function') {
|
||||||
|
|||||||
Vendored
+1374
-5408
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>
|
</footer>
|
||||||
|
|
||||||
<script src="vendor/jquery-1.9.0.min.js" type="text/javascript"></script>
|
<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="../dist/quagga.js" type="text/javascript"></script>
|
||||||
<script src="live_w_locator.js" type="text/javascript"></script>
|
<script src="live_w_locator.js" type="text/javascript"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+1312
-5349
File diff suppressed because one or more lines are too long
+3
-4
@@ -60,8 +60,8 @@
|
|||||||
"phantomjs": "^1.9.18",
|
"phantomjs": "^1.9.18",
|
||||||
"sinon": "^1.17.7",
|
"sinon": "^1.17.7",
|
||||||
"sinon-chai": "^2.8.0",
|
"sinon-chai": "^2.8.0",
|
||||||
"webpack": "^2.2.0-rc.3",
|
"webpack": "^2.2.1",
|
||||||
"webpack-sources": "^0.1.3"
|
"webpack-sources": "^0.1.4"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "doc"
|
"doc": "doc"
|
||||||
@@ -108,7 +108,6 @@
|
|||||||
"gl-vec3": "^1.0.3",
|
"gl-vec3": "^1.0.3",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"ndarray": "^1.0.18",
|
"ndarray": "^1.0.18",
|
||||||
"ndarray-linear-interpolate": "^1.0.0",
|
"ndarray-linear-interpolate": "^1.0.0"
|
||||||
"webrtc-adapter": "^2.0.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,42 +69,15 @@ function deprecatedConstraints(videoConstraints) {
|
|||||||
return normalized;
|
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) {
|
export function pickConstraints(videoConstraints) {
|
||||||
const normalizedConstraints = {
|
const normalizedConstraints = {
|
||||||
audio: false,
|
audio: false,
|
||||||
video: deprecatedConstraints(videoConstraints)
|
video: deprecatedConstraints(videoConstraints)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!normalizedConstraints.video.deviceId) {
|
if (normalizedConstraints.video.deviceId
|
||||||
if (typeof normalizedConstraints.video.facingMode === 'string'
|
&& normalizedConstraints.video.facingMode) {
|
||||||
&& normalizedConstraints.video.facingMode.length > 0) {
|
delete normalizedConstraints.video.facingMode;
|
||||||
return pickDevice(normalizedConstraints);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Promise.resolve(normalizedConstraints);
|
return Promise.resolve(normalizedConstraints);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import TypeDefs from './common/typedefs'; // eslint-disable-line no-unused-vars
|
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 ImageWrapper from './common/image_wrapper';
|
||||||
import BarcodeLocator from './locator/barcode_locator';
|
import BarcodeLocator from './locator/barcode_locator';
|
||||||
import BarcodeDecoder from './decoder/barcode_decoder';
|
import BarcodeDecoder from './decoder/barcode_decoder';
|
||||||
|
|||||||
Reference in New Issue
Block a user