Change Settings
Scan Settings
API Name | Description |
---|---|
whenToPlaySoundforSuccessfulRead | Sets when to play sound on text recognition. |
soundOnSuccessfullRead | Specifies the sound to play on text recognition. |
whenToVibrateforSuccessfulRead | Sets when to vibrate on text recognition. |
vibrateDuration | Returns or sets how long the vibration lastsin milliseconds. |
getScanSettings() | Returns the current scan settings. |
updateScanSettings() | Changes scan settings with the object passed in. |
Runtime Settings
API Name | Description |
---|---|
updateRuntimeSettingsFromString() | Updates runtime settings with a template represented by a JSON string. |
outputSettingsToString() | Output the current runtime settings to a JSON string. |
whenToPlaySoundforSuccessfulRead
Sets when to play sound on text recognition (user input is required on iOS or Chrome for any sound to play). Allowed values are
never
: never play sound, the default value;frame
: play sound when text is found on a frame;unique
: play sound when a unique new text is found (if multiple unique barcodes are found on the same frame, play only once).
whenToPlaySoundforSuccessfulRead: (boolean | string)
Default value
false
Code Snippet
// A user gesture required.
startPlayButton.addEventListener('click', function() {
recognizer.whenToPlaySoundforSuccessfulRead = true;
});
soundOnSuccessfullRead
Specifies the sound to play on text recognition. If not specified, the default one is used.
soundOnSuccessfullRead: HTMLAudioElement
Code Snippet
recognizer.soundOnSuccessfullRead = new Audio("./pi.mp3");
See also
whenToVibrateforSuccessfulRead
Sets when to vibrate on text recognition (user input is required in Chrome for the vibration). It only supports Android Devices with a vibrating system. Allowed values are
never
: never vibrate, the default value;frame
: vibrate when text is found on a frame;unique
: vibrate when a unique new text is found (if multiple unique barcodes are found on the same frame, vibrate only once).
whenToVibrateforSuccessfulRead: (boolean | string)
Default value
false
Code Snippet
// Can I use? https://caniuse.com/?search=vibrate
startVibrateButton.addEventListener('click', function() {
recognizer.whenToVibrateforSuccessfulRead = true;
});
vibrateDuration
Returns or sets how long the vibration lasts in milliseconds. It only supports Android Devices with a vibrating system. The default value is 300
.
vibrateDuration: number
See also
getScanSettings
Returns the current scan settings.
getScanSettings(): Promise<ScanSettings>
Parameters
None.
Return value
A promise resolving to a ScanSettings
.
Code Snippet
let scanSettings = await recognizer.getScanSettings();
scanSettings.intervalTime = 50;
scanSettings.duplicateForgetTime = 1000;
await recognizer.updateScanSettings(scanSettings);
See also
updateScanSettings
Changes scan settings with the object passed in.
updateScanSettings(settings: ScanSettings): Promise<void>
Parameters
settings
: specifies the new scan settings.
Return value
A promise that resolves when the operation succeeds.
Code Snippet
let scanSettings = await recognizer.getScanSettings();
scanSettings.intervalTime = 50;
scanSettings.duplicateForgetTime = 1000;
await recognizer.updateScanSettings(scanSettings);
See also
updateRuntimeSettingsFromString
Updates runtime settings with a template represented by a JSON string.
updateRuntimeSettingsFromString(runtimeSettings: string): Promise<void>
Parameters
runtimeSettings
: a JSON string that specifies the runtime settings or one of the built-in runtimeSettings
templates which include
Name | Description |
---|---|
number |
For pure number recognition. |
numberLetter |
For number and English letter recognition. |
numberUpperCase |
For number and uppercase English letter recognition. |
letter |
For pure English letter recognition. |
passportMRZ |
For passport MRZ recognition. |
visaMRZ_A |
For Visa (Country not Credit Card) MRZ recognition. |
VIN |
For VIN (vehicle identification number) recognition. |
VIN_NA |
For North American VIN (vehicle identification number) recognition. |
When recognizing from video input, add the prefix “video-“ for a slightly different template optimized for continuous frame recognition. For example, use video-passportMRZ
to read the MRZ on passports with a camera.
Return value
A promise resolving to the created LabelRecognizer
object.
Return value
A promise that resolves when the operation succeeds.
outputRuntimeSettingsToString
Output the current runtime settings to a JSON string.
outputRuntimeSettingsToString(): Promise<string>;
Parameters
None.
Return value
A promise resolving to a JSON string that represents the runtime settings.