Errors and permissions
Camera failures are ordinary and expected: permission denied, no camera, camera already in use. The component classifies each one so an application can respond without parsing message text.
Provoke a failure
An unknown DeviceId is requested as an exact constraint, so browsers
reject it with OverconstrainedError, which the component reports as
ConstraintsUnsatisfied.
RequestedWidth and RequestedHeight are sent as
ideal constraints, so an unreachable resolution is negotiated down rather
than refused; resolution alone never produces an error.
To see a permission denial, block camera access for this site in the browser and press Start normally.
Current state
Error kinds
Every failure reaches OnError as a BbScannerException whose
Kind is one of these.
| Kind | Meaning |
|---|---|
| PermissionDenied | The user or a policy refused the camera. |
| NoCamera | No device matched the request. |
| CameraUnavailable | A device exists but is held by something else. |
| ConstraintsUnsatisfied | No camera can meet the requested constraints. |
| NotSupported | No camera API, or the page is not a secure context. |
| Unknown | Anything the browser did not classify. |
Secure context
Browsers only expose getUserMedia over HTTPS or on
localhost. Served any other way the component reports
NotSupported immediately, with a message that says exactly that,
instead of hanging on a permission prompt that will never appear.