STRICH Barcode Scanning SDK API Reference
    Preparing search index...

    Class BarcodeReader

    BarcodeReader is the primary interface of the STRICH SDK.

    Index

    Constructors

    • Create a new BarcodeReader using a Configuration object.

      Parameters

      Returns BarcodeReader

      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

    cameraSelector?: CameraSelector

    Optional app-supplied camera selector.

    The callback receives a list of available cameras as its argument and must return one of the objects. In all other cases, the callback's result will be ignored and the default camera selection logic will apply

    The callback must be set before calling BarcodeReader#initialize to have an effect.

    This is an advanced property and should only be used in special circumstances where you really need to force a specific camera to be used.

    detected?: DetectionHandler

    App-supplied barcode detection handler.

    onError?: (error: Error) => void

    Optional app-supplied error callback, invoked by the BarcodeReader if an unexpected error occurred while processing frames.

    Methods

    • Destroy this BarcodeReader instance, making it unusable.

      Returns Promise<void>

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

      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.

      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.

    • Programmatically toggle the flashlight if the device supports it.

      Parameters

      • enabled: boolean

        True to enable the flashlight, false to disable it

      Returns Promise<void>

      This method will do nothing if the BarcodeReader is not initialized or has been destroyed.

    • Show or hide the BarcodeReader instance.

      Parameters

      • visible: boolean

        True to display the BarcodeReader, false to hide it

      Returns Promise<void>

      This will not release the camera stream.

    • Programmatically zoom the camera feed if the device supports it.

      Parameters

      • enabled: boolean

        True to enable zoom, false to disable it

      Returns Promise<void>

      This method will do nothing if the BarcodeReader is not initialized or has been destroyed.

    • Start barcode recognition.

      Returns Promise<void>

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

    • Stop barcode recognition.

      Returns Promise<void>

      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.