BarcodeScanner
Name | Type | Default Value | Description |
---|---|---|---|
options | ScanOptions | DEFAULT_OPTIONS | / |
onCapture | (barcodes: DetectedBarcode[]) => any | / | Triggered when the specified QR code is scanned |
trackConstraints | MediaTrackConstraints | DEFAULT_CONSTRAINTS | Based on the MediaTrackConstraints (opens in a new tab) standard |
useCamera
Name | Type | Default Value | Description |
---|---|---|---|
ref | RefObject<HTMLVideoElement> | Required* | HTMLVideoElement instance |
trackConstraints | MediaTrackConstraints | DEFAULT_CONSTRAINTS | Based on the MediaTrackConstraints (opens in a new tab) standard |
DEFAULT_CONSTRAINTS
{
width: { min: 640, ideal: 1280 },
height: { min: 480, ideal: 720 },
facingMode: {
ideal: 'environment'
},
advanced: [
{ width: 1920, height: 1280 },
{ aspectRatio: 1.333 }
]
}
useScanning
Name | Type | Default Value | Description |
---|---|---|---|
ref | RefObject<HTMLVideoElement> | Required* | HTMLVideoElement instance |
options | ScanOptions | DEFAULT_OPTIONS | delay: scan interval formats: barcode format, support formats |
DEFAULT_OPTIONS
{
delay: 1000,
formats: ['qr_code']
}
useTorch
Name | Type | Default Value | Description |
---|---|---|---|
open | Boolean | false | Enabled by default |
useStreamState
Manage stream
obtained from useCamera
function useStreamState (): [MediaStream | undefined, (newState: MediaStream) => void]
Types
ScanOptions
interface ScanOptions {
delay?: number
formats?: string[]
}