Options
All
  • Public
  • Public/Protected
  • All
Menu

A barcode picker element used to get and show camera input and perform scanning operations.

The barcode picker will automatically fit and scale inside the given originElement.

Each barcode picker internally contains a Scanner object with its own WebWorker thread running a separate copy of the external Scandit Engine library. To optimize loading times and performance it's recommended to reuse the same picker and to already create the picker in advance (hidden) and just display it when needed whenever possible.

As the loading of the external Scandit Engine library can take some time the picker always starts inactive (but showing GUI and video) and then activates, if not paused, as soon as the library is ready to scan. The onReady method can be used to set up a listener function to be called when the library is loaded.

You are not allowed to hide the Scandit logo present in the corner of the GUI.

Hierarchy

  • BarcodePicker

Index

Methods

accessCamera

  • Access the currently set or default camera, requesting user permissions if needed. This method is meant to be used after the picker has been initialized with disabled camera access (cameraAccess=false). Calling this doesn't do anything if the camera has already been accessed.

    Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:

    • PermissionDeniedError
    • NotAllowedError
    • NotFoundError
    • AbortError
    • NotReadableError
    • InternalError
    • NoCameraAvailableError

    Returns Promise<BarcodePicker>

    A promise resolving to the updated BarcodePicker object when the camera is accessed.

applyCameraSettings

  • Try to apply new settings to the currently used camera for video input, if no settings are passed the default ones are set.

    If camera access is enabled, the camera is updated and accessed with the new settings.

    Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:

    • PermissionDeniedError
    • NotAllowedError
    • NotFoundError
    • AbortError
    • NotReadableError
    • InternalError
    • NoCameraAvailableError

    Parameters

    • Optional cameraSettings: CameraSettings

      The new camera options used when accessing the camera, by default HD resolution is used.

    Returns Promise<BarcodePicker>

    A promise resolving to the updated BarcodePicker object when the camera is updated (and accessed, if camera access is currently enabled).

applyScanSettings

  • Applies a new set of scan settings to the internal scanner (replacing old settings).

    Parameters

    • scanSettings: ScanSettings

      The scan configuration object to be applied to the scanner.

    Returns BarcodePicker

    The updated BarcodePicker object.

destroy

  • destroy(): void
  • Stop scanning and displaying video output, remove HTML elements added to the page, destroy the internal Scanner and destroy the barcode picker itself; ensuring complete cleanup.

    This method should be called after you don't plan to use the picker anymore, before the object is automatically cleaned up by JavaScript. The barcode picker must not be used in any way after this call.

    Returns void

getActiveCamera

  • getActiveCamera(): Camera | undefined
  • Returns Camera | undefined

    The currently active camera.

isMirrorImageEnabled

  • isMirrorImageEnabled(): boolean
  • Returns boolean

    Whether the camera video is mirrored along the vertical axis.

isPlaySoundOnScanEnabled

  • isPlaySoundOnScanEnabled(): boolean
  • Returns boolean

    Whether a sound should be played on barcode recognition (iOS requires user input).

isReady

  • isReady(): boolean
  • Returns boolean

    Whether the barcode picker has loaded the external Scandit Engine library and is ready to scan.

isScanningPaused

  • isScanningPaused(): boolean
  • Returns boolean

    Whether the scanning is currently paused.

isVibrateOnScanEnabled

  • isVibrateOnScanEnabled(): boolean
  • Returns boolean

    Whether the device should vibrate on barcode recognition (only Chrome & Firefox, requires user input).

isVisible

  • isVisible(): boolean
  • Returns boolean

    Whether the picker is in a visible state or not.

onReady

  • Add the listener function to the listeners array for the "ready" event, fired when the external Scandit Engine library has been loaded and the barcode picker can thus start to scan barcodes.

    No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.

    Parameters

    • listener: function

      The listener function.

        • (): void
        • Returns void

    Returns BarcodePicker

    The updated BarcodePicker object.

onScan

  • onScan(listener: function, once?: undefined | true | false): BarcodePicker
  • Add the listener function to the listeners array for the "scan" event, fired when new barcodes are recognized in the image frame. The returned barcodes are affected by the ScanSettings.setCodeDuplicateFilter option.

    No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.

    Parameters

    • listener: function

      The listener function, which will be invoked with a ScanResult object.

    • Optional once: undefined | true | false

      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

onScanError

  • onScanError(listener: function, once?: undefined | true | false): BarcodePicker
  • Add the listener function to the listeners array for the "scan error" event, fired when an error occurs during scanning initialization and execution. The barcode picker will be automatically paused when this happens.

    No checks are made to see if the listener has already been added. Multiple calls passing the same listener will result in the listener being added, and called, multiple times.

    Parameters

    • listener: function

      The listener function, which will be invoked with an ScanditEngineError object.

        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    • Optional once: undefined | true | false

      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

pauseScanning

  • Pause the recognition of codes in the input image, video from the camera is still shown.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeScanErrorListener

  • Removes the specified listener from the "scan error" event listener array. This will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times then this method must be called multiple times to remove each instance.

    Parameters

    • listener: function

      The listener function to be removed.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeScanErrorListeners

  • Removes all listeners from the "scan error" event listener array.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeScanListener

  • Removes the specified listener from the "scan" event listener array. This will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times then this method must be called multiple times to remove each instance.

    Parameters

    • listener: function

      The listener function to be removed.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeScanListeners

  • Removes all listeners from the "scan" event listener array.

    Returns BarcodePicker

    The updated BarcodePicker object.

resumeScanning

  • Resume the recognition of codes in the input image.

    Returns BarcodePicker

    The updated BarcodePicker object.

setActiveCamera

  • Select a camera to be used for video input.

    If camera access is enabled, the camera is enabled and accessed.

    Depending on device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:

    • PermissionDeniedError
    • NotAllowedError
    • NotFoundError
    • AbortError
    • NotReadableError
    • InternalError
    • NoCameraAvailableError

    Parameters

    • camera: Camera

      The new camera to be used.

    • Optional cameraSettings: CameraSettings

      The camera options used when accessing the camera, by default HD resolution is used.

    Returns Promise<BarcodePicker>

    A promise resolving to the updated BarcodePicker object when the camera is set (and accessed, if camera access is currently enabled).

setGuiStyle

  • Set the GUI style for the picker.

    Parameters

    • guiStyle: GuiStyle

      The new GUI style to be applied.

    Returns BarcodePicker

    The updated BarcodePicker object.

setMirrorImageEnabled

  • Enable or disable camera video mirroring along the vertical axis.

    Parameters

    • enabled: boolean

      Whether the camera video is mirrored along the vertical axis.

    Returns BarcodePicker

    The updated BarcodePicker object.

setPlaySoundOnScanEnabled

  • Enable or disable playing a sound on barcode recognition (iOS requires user input).

    Parameters

    • enabled: boolean

      Whether a sound should be played on barcode recognition.

    Returns BarcodePicker

    The updated BarcodePicker object.

setTorchEnabled

  • Enable or disable the torch/flashlight of the device (when available, only Chrome). Changing active camera or camera settings will cause the torch to become disabled.

    A button on the BarcodePicker GUI to let the user toggle this functionality can also be set on creation via the enableTorchToggle option (enabled by default, when available).

    Parameters

    • enabled: boolean

      Whether the torch should be enabled or disabled.

    Returns BarcodePicker

    The updated BarcodePicker object.

setVibrateOnScanEnabled

  • Enable or disable vibrating the device on barcode recognition (only Chrome & Firefox, requires user input).

    Parameters

    • enabled: boolean

      Whether the device should vibrate on barcode recognition.

    Returns BarcodePicker

    The updated BarcodePicker object.

setVisible

  • Enable or disable picker visibility.

    Parameters

    • visible: boolean

      Whether the picker is in a visible state or not.

    Returns BarcodePicker

    The updated BarcodePicker object.

Static create

  • create(originElement: HTMLElement, __namedParameters?: object): Promise<BarcodePicker>
  • Creates a BarcodePicker instance, creating the needed HTML in the given origin element. If the accessCamera is enabled (active by default) the available cameras are accessed and a camera access permission is requested to the user if needed. This object expects that at least a camera is available. The active camera is accessed and kept active during the lifetime of the picker (also when hidden or scanning is paused), and is only released when destroy is called.

    It is required to having configured the library via configure before this object can be created.

    Depending on parameters, device features and user permissions for camera access, any of the following errors could be the rejected result of the returned promise:

    • LibraryNotConfiguredError
    • NoOriginElementError
    • UnsupportedBrowserError
    • PermissionDeniedError
    • NotAllowedError
    • NotFoundError
    • AbortError
    • NotReadableError
    • InternalError
    • NoCameraAvailableError

    Parameters

    • originElement: HTMLElement

      The HTMLElement inside which all the necessary elements for the picker will be added.

    • Default value __namedParameters: object = {}
      • accessCamera: boolean

        Default = true
        Whether to immediately access the camera (and requesting user permissions if needed) on picker creation.

      • camera: undefined | Camera

        Default = undefined
        The camera to be used for video input, if not specified the back or only camera will be used.

      • cameraSettings: undefined | CameraSettings

        Default = undefined
        The camera options used when accessing the camera, by default HD resolution is used.

      • enableCameraSwitcher: boolean

        Default = true
        Whether to show a GUI button to switch between different cameras (when available).

      • enableTapToFocus: boolean

        Default = true
        Whether to trigger a manual focus of the camera when clicking/tapping on the video (when available, only Chrome).

      • enableTorchToggle: boolean

        Default = true
        Whether to show a GUI button to toggle device torch on/off (when available, only Chrome).

      • guiStyle: GuiStyle

        Default = GuiStyle.LASER
        The GUI style for the picker.

      • playSoundOnScan: boolean

        Default = false
        Whether a sound is played on barcode scanned (iOS requires user input).

      • scanSettings: ScanSettings

        Default = new ScanSettings()
        The configuration object for scanning options (All symbologies disabled by default).

      • scanningPaused: boolean

        Default = false
        Whether the picker starts in a paused scanning state.

      • vibrateOnScan: boolean

        Default = false
        Whether the device vibrates on barcode scanned (only Chrome & Firefox, requires user input).

      • visible: boolean

        Default = true
        Whether the picker starts in a visible state.

    Returns Promise<BarcodePicker>

    A promise resolving to the created ready BarcodePicker object.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc