This page is applicable to version 8.2.3
Javascript API Reference - BarcodeScanner
Capture Settings
Method | Description |
---|---|
getCapabilities() | Get the camera capabilities. |
getResolution() | Get current video resolution. |
setResolution() | Set current video resolution. |
getScanSettings() | Get current scan settings. |
updateScanSettings() | Modify and update scan settings. |
getVideoSettings() | Get current video settings. |
updateVideoSettings() | Modify and update video settings. |
setColorTemperature() | Adjust the video colour temperature. |
setExposureCompensation() | Adjust the video exposure level. |
setFrameRate() | Adjust the video frame rate. |
setZoom() | Adjust the video zoom ratio. |
turnOffTorch() | Turn off the torch/flashlight. |
turnOnTorch() | Turn on the torch/flashlight. |
getCapabilities
Get the camera capabilities.
This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported.
getCapabilities() returns MediaTrackCapabilities
Return Value
MediaTrackCapabilities
Example
> scanner.getCapabilities()
< {
"aspectRatio":{"max":3840,"min":0.000462962962962963},
"colorTemperature": {max: 7000, min: 2850, step: 50},
"deviceId":"1e...3af7",
"exposureCompensation": {max: 2.0000040531158447, min: -2.0000040531158447, step: 0.16666699945926666},
"exposureMode":["continuous","manual"],
"facingMode":["environment"],
"focusMode":["continuous","single-shot","manual"],
"frameRate":{"max":30,"min":0},
"groupId":"71...a935",
"height":{"max":2160,"min":1},
"resizeMode":["none","crop-and-scale"],
"torch":true,
"whiteBalanceMode":["continuous","manual"],
"width":{"max":3840,"min":1},
"zoom":{max: 606, min: 100, step: 2}
}
Tips and Tricks
Check out the following APIs to modify your device capabilities (if supported).
- setColorTemperature - Adjust the video colour temperature.
- setExposureCompensation - Adjust the video exposure level.
- setFrameRate - Adjust the video frame rate.
- setZoom - Adjust the video zoom ratio.
- turnOffTorch - Turn off the torch/flashlight.
- turnOnTorch -Turn on the torch/flashlight.
getResolution
Get current video resolution.
getResolution() returns number[]
Return Value
number[]
Sample
let rsl = await scanner.getResolution();
console.log(rsl.width + " x " + rsl.height);
Read barcodes from live camera
setResolution
Set the camera resolution.
setResolution(width, height) returns Promise
Parameters
-
width
numbernumber[] -
height
number
Return Value
Promise<ScannerPlayCallbackInfo>
Sample
Read barcodes from live camera
getScanSettings
Get current scan settings of BarcodeScanner
and saves it into a struct.
getScanSettings() returns Promise
Return Value
Promise<ScanSettings>
Sample
Read barcodes from live camera
updateScanSettings
Modify and update scan settings.
updateScanSettings(settings) returns Promise
Parameters
settings
ScanSettings
Return Value
Promise<void>
Sample
Read barcodes from live camera
getVideoSettings
Get current video settings of BarcodeScanner
and saves it into a struct.
getVideoSettings() returns MediaStreamConstraints
Return Value
MediaStreamConstraints
Sample
Read barcodes from live camera
updateVideoSettings
Modify and update video settings.
updateVideoSettings(MediaStreamConstraints) returns Promise
Parameters
MediaStreamConstraints
any
Return Value
Promise<ScannerPlayCallbackInfo | void>
Sample
await scanner.updateVideoSettings({
video: { width: { ideal: 1280 },
height: { ideal: 720 },
facingMode: { ideal: 'environment' }
}
});
Read barcodes from live camera
setColorTemperature
Adjust the video colour temperature.
This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported. Check if this capability is supported by the camera using getCapabilities.
setColorTemperature(value) returns Promise
Parameters
value
number
Return Value
Promise<void>
Sample
Read barcodes from live camera
setExposureCompensation
Adjust the video exposure level.
This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported. Check if this capability is supported by the camera using getCapabilities.
setExposureCompensation(value) returns Promise
Parameters
value
number
Return Value
Promise<void>
Sample
Read barcodes from live camera
setFrameRate
Adjust the video frame rate.
This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported. Check if this capability is supported by the camera using getCapabilities.
setFrameRate(value) returns Promise
Parameters
value
number
Return Value
Promise<void>
Sample
Read barcodes from live camera
setZoom
Adjust the video zoom ratio.
This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported. Check if this capability is supported by the camera using getCapabilities.
setZoom(value) returns Promise
Parameters
value
number
Return Value
Promise<void>
Sample
Read barcodes from live camera
turnOffTorch
Turn off the torch/flashlight.
This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported. Check if this capability is supported by the camera using getCapabilities.
turnOffTorch() returns Promise
Return Value
Promise<void>
Sample
Read barcodes from live camera
turnOnTorch
Turn on the torch/flashlight.
This method should be called when the camera is turned on. Note that it only works with Chromium-based browsers such as Edge and Chrome on Windows or Android. Other browsers such as Firefox or Safari are not supported. Note that all browsers on iOS (including Chrome) use WebKit as the rendering engine and are not supported. Check if this capability is supported by the camera using getCapabilities.
turnOnTorch() returns Promise
Return Value
Promise<void>