Dev Center
Table of contents

Javascript API Reference - BarcodeScanner Properties

Property Description
bPlaySoundOnSuccessfulRead Set when a sound is played if a barcode is read successfully.
barcodeFillStyle Set the style used when filling in located barcode.
barcodeLineWidth Set the width of the located barcode border.
barcodeStrokeStyle Set the style of the located barcode border.
regionMaskFillStyle Set the style used when filling the mask beyond the region.
regionMaskLineWidth Set the width of the region border.
regionMaskStrokeStyle Set the style of the region border.
onFrameRead Triggered a frame has been scanned.
onPlayed Triggered when the camera video stream is played.
onUnduplicatedRead Triggered when a new, unduplicated barcode is found.

Inherited Properties From BarcodeReader

Property Description
_bUseFullFeature If set to true, use the fully-featured WASM module.
bDestroyed Indicates whether a BarcodeScanner object has been destroyed.
bSaveOriCanvas If set to true, save the original image to canvas.
oriCanvas The original canvas element.

bPlaySoundOnSuccessfulRead

Set when a sound is played if a barcode is read successfully. Default value is false, which does not play a sound.

Use frame or true to play a sound when any barcode is found within a frame. Use unduplicated to play a sound only when any unique/unduplicated barcode is found within a frame.

scanner.bPlaySoundOnSuccessfulRead = false;

scanner.bPlaySoundOnSuccessfulRead = true;

scanner.bPlaySoundOnSuccessfulRead = "frame";

scanner.bPlaySoundOnSuccessfulRead = "unduplicated";

barcodeFillStyle

Set the style used when filling in the located barcode.

barcodeFillStyle = "rgba(red, green, blue, alpha)"

Property Values

  • red number
  • green number
  • blue number
  • alpha number

barcodeStrokeStyle

Set the style of the located barcode border.

barcodeStrokeStyle = "rgba(red, green, blue, alpha)"

Property Values

  • red number
  • green number
  • blue number
  • alpha number

regionMaskFillStyle

Set the style used when filling the mask beyond the region.

regionMaskFillStyle = "rgba(red, green, blue, alpha)"

Property Values

  • red number
  • green number
  • blue number
  • alpha number

regionMaskStrokeStyle

Set the style of the region border.

regionMaskStrokeStyle = "rgb(red, green, blue)"

Property Values

  • red number
  • green number
  • blue number

onFrameRead

This event is triggered when a single frame has been scanned. The results object contains all the barcode results that the reader was able to decode.

Type Declaration

(results: TextResult[]): void

Parameters

results TextResult[]

Return Value

void

Sample

scanner.onFrameRead = results => {
    for(let result of results){
        console.log(result.barcodeText);
    }
};

Read barcodes from live camera

onPlayed

This event is triggered the camera video stream is played.

Type Declaration

(info: ScannerPlayCallbackInfo): void

Parameters

info ScannerPlayCallbackInfo

Return Value

void

Sample

Read barcodes from live camera

onUnduplicatedRead

This event is triggered when a new, unduplicated barcode is found. txt holds the barcode text result. result contains the actual barcode result, including the text result. Old barcodes will be remembered for duplicateForgetTime.

Type Declaration

(txt: string, result: TextResult): void

Parameters

Return Value

void

Sample

scanner.onUnduplicatedRead = (txt, result) => {
    alert(txt);
    console.log(result);
};

Read barcodes from live camera

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

version 7.6.0

  • Latest version(10.2.10)
  • Version 10.x
    • Version 10.0.21
    • Version 10.0.20
  • Version 9.x
    • Version 9.6.40
    • Version 9.6.33
    • Version 9.6.32
    • Version 9.6.31
    • Version 9.6.30
    • Version 9.6.21
    • Version 9.6.20
    • Version 9.6.11
    • Version 9.6.10
    • Version 9.6.2
    • Version 9.6.1
    • Version 9.6.0
    • Version 9.3.1
    • Version 9.3.0
    • Version 9.2.13
    • Version 9.2.12
    • Version 9.2.11
    • Version 9.0.2
    • Version 9.0.1
    • Version 9.0.0
  • Version 8.x
    • Version 8.8.7
    • Version 8.8.5
    • Version 8.8.3
    • Version 8.8.0
    • Version 8.6.3
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.5
    • Version 8.2.3
    • Version 8.2.1
    • Version 8.2.0
    • Version 8.1.3
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
  • Version 7.x
    • Version 7.6.0
    • Version 7.5.0
Change +