Commit Graph
129 Commits
Author SHA1 Message Date
Daniel d704d3ab37 Don't open a second stream if we already have permission for device listing
This is an optimization but also a fix for iOS Safari which stops an already ongoing
stream when a second stream is opened, see https://bugs.webkit.org/show_bug.cgi?id=179363.

Fixes #125
2022-01-25 10:21:26 +01:00
Daniel a3e87bcf1e Remove limitation to MediaStreams as video srcObject 2022-01-25 10:21:26 +01:00
Daniel 2ba049f759 Switch to yarn 2022-01-25 10:21:26 +01:00
Daniel ce3189aeb0 Automatically generate type declarations 2022-01-25 10:21:26 +01:00
Daniel bcd5b19f82 Convert to typescript 2022-01-25 10:20:37 +01:00
Daniel ffdb944b62 Update closure compiler
Now generates slightly smaller builds
2022-01-20 09:10:15 +01:00
Daniel 8041e59ad7 Add legacy ECMAScript 2015 (ES6) build 2022-01-19 20:57:10 +01:00
Daniel 8bf0dc47aa Convert to ES2017 with async/await
Also saves 4.3% in size for qr-scanner.min.js
2022-01-19 17:58:59 +01:00
Daniel 72049e55bd v1.3.0 2021-08-17 12:37:09 +02:00
Daniel a1493c127d Check whether BarcodeDetector.getSupportedFormats exists
Some browsers (iOS specific?) had issues, see issue #115.
2021-08-17 12:10:51 +02:00
Daniel f232f32211 Support hasFlash even if no stream is currently running
But still doing it after scanner.start() is recommended, to avoid creating
a temporary stream.
2021-08-17 12:02:35 +02:00
Daniel 2877944bce Refactor hasFlash to potentially support Firefox and Safari in the future 2021-08-17 08:53:28 +02:00
Daniel fe31236d51 Fix turning flash off
applyConstraints with torch: false does not work to turn the
flashlight off, as a stream's torch stays continuously on, see
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#torch.
Therefore, we have to stop the stream to turn the flashlight off.
2021-08-16 21:20:32 +02:00
Daniel e2edfe1e88 Restart the flash if it was previously on
Also now support flagging the flash as on while the stream is
paused.
2021-08-16 21:14:29 +02:00
Daniel 5f13ff064e Merge PR#112 (lafriks-fork:feat/camera_list) with fixes 2021-08-16 14:08:30 +02:00
Daniel 4cfaf31fe5 Demo: update flash availability when switching camera 2021-08-16 14:03:56 +02:00
Daniel 28c43cdbe3 Simplify and improve setCamera
- Use .pause instead of copying the code
- Remove the unnecessary 300ms delay
- Avoid overwriting _offTimeout if another pause call happened shortly
  before.
- Don't start the stream if is was paused.
2021-08-16 13:40:56 +02:00
Daniel 6a6c593c2d Merge deviceId and preferredFacingMode into preferredCamera
- Merge deviceId and preferredFacingMode options into a single
  option preferredCamera. Also previously, the deviceId took
  precedence over the preferredFacingMode.
- .setCamera now also allows setting a preferred facingMode
  instead of a deviceId.

Additinal fixes to PR#112:

- Correctly fallback to not applying any constraints in .start if
  the preferredCamera (previously deviceId and preferredFacingMode)
  is not available. Previously, if neither for the deviceId nor
  the preferredFacingMode contraint a camera was found, no attempt
  without a constraint was attempted.
- A add missing documentation for deviceId support in the constructor
  to the Readme and generally adapt Readme for merged preferredCamera
  option.
- Fix missing type for deviceId (now merged into preferredCamera) in
  the constructor type definitions and generally adapt the types for
  merged preferredCamera option.
2021-08-14 14:13:33 +02:00
Daniel 1e9f6c6598 Refactor listCameras and improve readme wording
- rename the method from getCameraList to listCameras
- make requesting labels (and the required camera permission) optional
- refactor hasCamera using listCameras

Additinal fixes to PR#112:

- add fallback labels for when no exact labels were requested
- remove unnecessary outer Promise
- make sure the created stream is always destroyed in a finally
2021-08-13 20:49:59 +02:00
Daniel 450de34ae3 Update our jsQR fork
Especially with the following changes:
- Attempt to fix Safari RangeError exceptions
- Support "structured append" qr codes
- Binarizer: adapt blackBias for slightly higher detection rate
2021-08-10 21:00:35 +02:00
Daniel d7a09be088 Avoid that Safari stops the video stream on hidden videos 2021-08-09 11:22:27 +02:00
Daniel e8d107a171 Performance improvements
- round scan region to whole pixel positions to avoid blurry
  drawing at sub-pixel positions
- avoid clearing the canvas by resetting the canvas width or
  height when they actually didn't change.
2021-07-29 19:37:15 +02:00
Daniel 5836ac719b Rename fixedCanvasSize to disallowCanvasResizing 2021-07-29 17:26:29 +02:00
TheAppleFreakandSören Schwert 83ed4002c5 Corrected typo in typings 2021-07-21 13:14:35 +02:00
Lauris BH 63f79f97a8 Change setCamera to be async method 2021-06-10 17:31:17 +03:00
Lauris BH 10d86390d6 Add new method definitions 2021-06-04 15:14:02 +03:00
Lauris BH 2f924b634f Add documentation in readme 2021-06-04 12:06:23 +03:00
Lauris BH c53a1ecb4a Add option to get camera list and allow to set specific device to use 2021-06-04 12:00:40 +03:00
Daniel e8a77dea3f Add option for providing a custom web cam scanning region 2020-07-12 18:57:29 +02:00
Daniel 89201b62e8 v1.2.0 2020-07-12 14:21:57 +02:00
Daniel 99111ae23a When the native BarcodeDetector crashed, create a new one
The BarcodeDetector sometimes crashes after some time. If that happens,
create a new one.
2020-07-12 13:01:05 +02:00
Daniel 423101663b Use native BarcodeDetector when supported 2020-07-12 12:30:38 +02:00
Daniel 87336c313b Update source rect when video ready
b3713f2 switched to starting to play immediately, without waiting for
a canplay event. The side effect of this is, that the play event (on
which the source rect is measured) is triggered before the video
is ready and the video dimensions known. To circumvent this, this
commit adds an additional source rect update on loadedmetadata.
2020-07-12 00:00:56 +02:00
Daniel ecc04840dd Increase the timeout
Sometimes when the scanner was processing a frame for a long time, the
timeout apparently could be triggered when it shouldn't.
2020-07-11 10:05:49 +02:00
Daniel f1ca69bb1e Readme: add documentation for some so far undocumented features
- support for image urls and data urls
- support for stopping web cam scanning via stop()
- support for hasCamera() check
- documentation for optional scanImage() parameters
- update file sizes
- list web cam scanning out-of-the-box as a feature of this lib
2020-07-11 10:04:57 +02:00
Daniel 509232f8d1 Support blobs as image source 2020-07-10 20:42:48 +02:00
Daniel 9ec0d32131 Add an umd build 2020-07-10 00:10:45 +02:00
Daniel c0f922bdda Update jsQR scanner lib
New version of our jsQR-es6 fork has been updated to newest master
of cozmo/jsQR and merged in additional pull requests which are still
open in cozmo/jsQR. Also now makes the 'onlyInvert' inversion mode
usable.
2020-07-09 21:58:13 +02:00
Daniel efaec08208 Update all dependencies and rebuild 2020-07-09 17:20:10 +02:00
Daniel 4206f44c22 Make sure hasCamera() always returns a Promise 2020-07-09 16:36:44 +02:00
Daniel a3fcd4cf69 Fixes and improvements for flashlight support
- Add instructions to readme
- Update _flashOn after the flash was actually turned on or off
- Throw an error when trying to set the flash if not supported
- Make toggleFlash, turnFlashOn, turnFlashOff return a promise
- Throw an error when trying to detect flash support before the
  video stream is available.
2020-07-09 14:31:41 +02:00
Filip ChalupaandDaniel 50adecec26 Flash detection and control
PR #34

Co-authored-by: Daniel <github.danimoh@neverbox.com>
2020-07-09 12:38:31 +02:00
Magnus HenochandDaniel 49ccc1dde9 Allow specifying a preferred facingMode for camera
PR #35

Co-authored-by: Daniel <github.danimoh@neverbox.com>
2020-07-09 11:33:38 +02:00
Daniel 947fb7ebcf Improvements and fixes for continous scanning error handling
- Make change backwards compatible with previous consructor signature
- Fix demo to interpret errors as proper results
- Update types
- Do not report errors when the scanner is inactive
- Update readme
2020-07-07 23:45:49 +02:00
diegoandDaniel 0961d4e102 add error for continous scanning 2020-07-07 15:52:08 +02:00
DanielandGustavo Honorato ee9e8f6fe6 Readme: improve webpack usage instructions
Improve the instructions for file-loader and add instructions for
raw-loader (see PR #60).

Co-authored-by: Gustavo Honorato <gustavohonorato@gmail.com>
2020-07-07 14:36:50 +02:00
Daniel 7776d8bca0 demo: add start and stop button 2020-07-06 23:31:20 +02:00
Daniel 1daf447a73 On pause stop all tracks if there are multiple
Should typically not be necessary, just to be safe.
2020-07-06 23:31:18 +02:00
DanielandAlessandro Gatti 177a252488 Set playsInline, muted and disablePictureInPicture by default
Set these properties by default to disable picture in picture mode and to
enable inline playback on iPhones.

Co-authored-by: Alessandro Gatti <ale.gatti96@gmail.com>
2020-07-06 23:30:36 +02:00
shrpneandDaniel 0ce0db151f Set correct video mirror for safari user facing cameras
Co-authored-by: Daniel <github.danimoh@neverbox.com>
2020-07-06 10:58:54 +02:00