BarcodeReader is the primary interface of the STRICH SDK.

Constructors

  • Create a new BarcodeReader using a Configuration object.

    Parameters

    Returns BarcodeReader

    Remarks

    This will perform some basic checks, such as if the SDK was initialized, the browser supports the required APIs and the host element is visible and has a non-zero size. This will not access the camera yet, that happens in the BarcodeReader#initialize method.

Properties

detected?: ((detections) => void)

User-supplied barcode detection handler.

This is a synchronous call, so further processing will not happen until the handler returns.

Type declaration

    • (detections): void
    • Parameters

      Returns void

onError?: ((error) => void)

Optional user-supplied error callback.

This is invoked by the BarcodeReader if an error occurred while processing frames, and is usually not recoverable.

Type declaration

    • (error): void
    • Parameters

      • error: Error

      Returns void

Methods

  • Destroy this BarcodeReader instance, making it unusable.

    Returns Promise<void>

    Promise that resolves when the BarcodeReader and its associated resources are fully destroyed.

    Remarks

    This will release all associated resources, including the camera stream, and should be called whenever an application no longer needs the BarcodeReader.

  • Returns boolean

    the current visibility of this BarcodeReader instance

  • Initialize the BarcodeReader instance.

    Returns Promise<BarcodeReader>

    A promise resolving to an initialized BarcodeReader instance, or an SdkError object.

    Remarks

    This will attempt to acquire a camera stream, so it is essential that the returned Promise is awaited, and that measures are taken so that the returned BarcodeReader instance is destroyed when it is no longer need. That will free the camera stream for subsequent use.

    If you are getting camera-related initialization errors, the most likely cause is that you are attempting to initialize a BarcodeReader and the camera feed has not been released yet.

  • Show or hide the BarcodeReader instance.

    Parameters

    • visible: boolean

      True to display the BarcodeReader, false to hide it

    Returns Promise<void>

    Remarks

    This will not release the camera stream.

  • Start barcode recognition.

    Returns Promise<void>

    Remarks

    The BarcodeReader instance must have previously been successfully initialized using the BarcodeReader#initialize method.

  • Stop barcode recognition.

    Returns Promise<void>

    Remarks

    This will suspend camera frame processing/barcode recognition, but will not release the camera stream. If you no longer intend to use the BarcodeReader instance, call BarcodeReader#destroy afterward.

    If you intend to only temporarily stop recognition of barcodes and resume later, call BarcodeReader#start again.