Skip to content

Commit 773d850

Browse files
committed
docs: describe camera prop
1 parent b8161f1 commit 773d850

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ Distributed content will overlay the camera stream, wrapped in a `position: abso
169169

170170
### `paused` prop
171171

172-
With the `paused` prop you can prevent further `decode` propagation and functions passed via `track` are stopped being called. Useful for example if you want to validate results one at a time. This will also freeze the camera stream.
172+
With the `paused` prop you can prevent further `decode` propagation. Functions passed via `track` are also stopped being called. Useful for example if you want to validate results one at a time.
173+
174+
> When the component is paused the camera stream freezes but is actually still running in the background. The browser will tell you that the camera is still in use. If you want to kill the stream completely you can pass `false` to the `camera` prop.
173175
174176
```html
175177
<qrcode-reader @decode="onDecode" :paused="paused"></qrcode-reader>
@@ -189,9 +191,15 @@ methods: {
189191
}
190192
```
191193

192-
### `video-constraints` prop
194+
### `camera` prop
195+
196+
With the `camera` prop you can filter the set of cameras installed on a client device. For example, if you want to access the front camera instead of the rear camera, pass this:
197+
198+
```html
199+
<qrcode-reader :camera="{ facingMode: 'user' }"></qrcode-reader>
200+
```
193201

194-
This component uses [getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) to request camera streams. This method accepts [a constraints object](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#Properties_of_video_tracks) to configure for example if front or rear camera should be accessed. This is passed by default:
202+
This component uses [getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) to request camera streams. This method accepts [a constraints object](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#Properties_of_video_tracks). By default this component passes this:
195203

196204
```javascript
197205
{
@@ -204,13 +212,17 @@ This component uses [getUserMedia](https://developer.mozilla.org/en-US/docs/Web/
204212
}
205213
```
206214

207-
You can change the `video` part using the `video-constraints` prop. Note that you only have to pass properties you want to override. If you want to use the front camera for example and change nothing else, pass this:
215+
This `video` part in this object is essentially what you can change using the `camera` prop. Note that you only have to pass properties you want to override. All the other default properties on the first depth level are preserved. Here are a few examples:
208216

209-
```html
210-
<qrcode-reader :video-constraints="{ facingMode: 'user' }"></qrcode-reader>
211-
```
217+
`camera="{ facingMode: 'user' }"`: the `facingMode` property is passed and is the only property that changes. `width` and `height` are still the default value.
218+
219+
`camera="false"`: overrides ALL default properties. No camera can match those constraints so no camera is request in the first place. You can use this to turn of the camera at runtime.
220+
221+
`camera="{}"`: since an empty object does not contain properties that could override something, this is just like falling back to the default. The same as not using the `camera` prop at all or passing `undefined`/`null`.
222+
223+
`camera="true"`: overrides ALL default properties. You will accept any camera type there is. Not recommended though as iOS seems to have trouble when the `height` and `width` constraints are missing.
212224

213-
> If you change this property after initialization, a new camera stream will be requested and the `init` event will be emitted again.
225+
> If you change this property after initialization, a new camera stream has to be requested and the `init` event will be emitted again.
214226
215227

216228
# Installation

0 commit comments

Comments
 (0)