Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BarcodePicker

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 on method targeting the ready event can be used to set up a listener function to be called when the library is loaded.

The picker can also operate in "single image mode", letting the user click/tap to take a single image to be scanned via the camera (mobile/tablet) or a file select dialog (desktop). This is provided automatically as fallback by default when the OS/browser only supports part of the needed features and cannot provide direct access to the camera for video streaming and continuous scanning, or can also be forced. This behaviour can be set up on creation. Note that in this mode some of the functions provided by the picker will have no effect.

By default an alert is shown if an internal error during scanning is encountered which prevents the scanning procedure from continuing when running on a local IP address. As this uses the built-in scanError event functionality, if unwanted it can be disabled by calling removeAllListeners on the BarcodePicker instance (right after creation).

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

Hierarchy

  • BarcodePicker

Index

Events

Static processFrame

  • Fired when a new frame is processed by the engine. This event is fired on every frame, independently from the number of recognized barcodes (can be none). The returned barcodes are affected by the ScanSettings.setCodeDuplicateFilter option.

    asmemberof

    BarcodePicker

    Parameters

    • scanResult: ScanResult

      The result of the scanning operation on the image.

    Returns void

Static ready

  • ready(): void
  • Fired when the external Scandit Engine library has been loaded and the barcode picker can thus start to scan barcodes.

    asmemberof

    BarcodePicker

    Returns void

Static scan

  • Fired when new barcodes are recognized in the image frame. The returned barcodes are affected by the ScanSettings.setCodeDuplicateFilter option.

    asmemberof

    BarcodePicker

    Parameters

    • scanResult: ScanResult

      The result of the scanning operation on the image.

    Returns void

Static scanError

  • scanError(error: Error): void
  • Fired when an error occurs during scanning initialization and execution. The barcode picker will be automatically paused when this happens.

    asmemberof

    BarcodePicker

    Parameters

    • error: Error

      The ScanditEngineError that was triggered.

    Returns void

Static submitFrame

  • Fired when a new frame is submitted to the engine to be processed. As the frame is not processed yet, the ScanResult.barcodes property will always be empty (no results yet).

    asmemberof

    BarcodePicker

    Parameters

    • scanResult: ScanResult

      The result of the scanning operation on the image.

    Returns void

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 (accessCamera=false) or after pauseScanning has been called with the pause camera stream option. Calling this doesn't do anything if the camera is already being 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

    In "single image mode" this method has no effect.

    Returns Promise<BarcodePicker>

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

addListener

  • addListener(eventName: EventName, listener: ListenerFn, once?: undefined | false | true): BarcodePicker
  • See the on method.

    Parameters

    • eventName: EventName

      The name of the event to listen to.

    • listener: ListenerFn

      The listener function.

    • Optional once: undefined | false | true
      Default = false
      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

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

    In "single image mode" this method has no effect.

    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

  • Apply 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.

clearSession

  • Clear the internal scanner session.

    This removes all recognized barcodes from the scanner session and allows them to be scanned again in case a custom codeDuplicateFilter was set in the ScanSettings.

    Returns BarcodePicker

    The updated BarcodePicker object.

createParserForFormat

  • Create a new parser object.

    Parameters

    • dataFormat: DataFormat

      The format of the input data for the parser.

    Returns Parser

    The newly created parser.

destroy

  • destroy(destroyScanner?: boolean): void
  • Stop scanning and displaying video output, remove HTML elements added to the page, destroy the internal Scanner (by default) 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.

    If the Scanner is or will be in use for other purposes, the relative option can be passed to prevent its destruction.

    Parameters

    • Default value destroyScanner: boolean = true

      Whether to destroy the internally used Scanner or not.

    Returns void

getActiveCamera

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

    The currently active camera.

getScanner

  • Returns Scanner

    The internally used initialized (and possibly configured) Scanner object instance.

isCameraSwitcherEnabled

  • isCameraSwitcherEnabled(): boolean
  • Returns boolean

    Whether a GUI button to switch between different cameras is shown (when available).

isMirrorImageEnabled

  • isMirrorImageEnabled(): boolean
  • Returns boolean

    Whether the currently selected camera's video is mirrored along the vertical axis.

isPinchToZoomEnabled

  • isPinchToZoomEnabled(): boolean
  • Returns boolean

    Whether camera zoom control via pinching gesture on the video is enabled (when available, only Chrome).

isPlaySoundOnScanEnabled

  • isPlaySoundOnScanEnabled(): boolean
  • Returns boolean

    Whether a sound should be played on barcode recognition (iOS requires user input). Note that the sound is played if there's at least a barcode not rejected via ScanResult.rejectCode.

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.

isTapToFocusEnabled

  • isTapToFocusEnabled(): boolean
  • Returns boolean

    Whether manual camera focus when clicking/tapping on the video is enabled (when available, only Chrome).

isTorchToggleEnabled

  • isTorchToggleEnabled(): boolean
  • Returns boolean

    Whether a GUI button to toggle device torch on/off is shown (when available, only Chrome).

isVibrateOnScanEnabled

  • isVibrateOnScanEnabled(): boolean
  • Returns boolean

    Whether the device should vibrate on barcode recognition (only Chrome & Firefox, requires user input). Note that the vibration is triggered if there's at least a barcode not rejected via ScanResult.rejectCode.

isVisible

  • isVisible(): boolean
  • Returns boolean

    Whether the picker is in a visible state or not.

on

  • on(eventName: EventName, listener: ListenerFn, once?: undefined | false | true): BarcodePicker
  • on(eventName: "ready", listener: function): BarcodePicker
  • on(eventName: "submitFrame", listener: function, once?: undefined | false | true): BarcodePicker
  • on(eventName: "processFrame", listener: function, once?: undefined | false | true): BarcodePicker
  • on(eventName: "scan", listener: function, once?: undefined | false | true): BarcodePicker
  • on(eventName: "scanError", listener: function, once?: undefined | false | true): BarcodePicker
  • Add the listener function to the listeners array for an event.

    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

    • eventName: EventName

      The name of the event to listen to.

    • listener: ListenerFn

      The listener function.

    • Optional once: undefined | false | true
      Default = false
      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

  • 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. If the library has already been loaded the listener is called immediately.

    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

    • eventName: "ready"

      The name of the event to listen to.

    • listener: function

      The listener function.

        • (): void
        • Returns void

    Returns BarcodePicker

    The updated BarcodePicker object.

  • Add the listener function to the listeners array for the submitFrame event, fired when a new frame is submitted to the engine to be processed. As the frame is not processed yet, the ScanResult.barcodes property will always be empty (no results yet).

    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

    • eventName: "submitFrame"

      The name of the event to listen to.

    • listener: function

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

    • Optional once: undefined | false | true
      Default = false
      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

  • Add the listener function to the listeners array for the processFrame event, fired when a new frame is processed. This event is fired on every frame, independently from the number of recognized barcodes (can be none). 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

    • eventName: "processFrame"

      The name of the event to listen to.

    • listener: function

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

    • Optional once: undefined | false | true
      Default = false
      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

  • 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

    • eventName: "scan"

      The name of the event to listen to.

    • listener: function

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

    • Optional once: undefined | false | true
      Default = false
      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

  • Add the listener function to the listeners array for the scanError 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

    • eventName: "scanError"

      The name of the event to listen to.

    • listener: function

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

        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    • Optional once: undefined | false | true
      Default = false
      Whether the listener should just be triggered only once and then discarded.

    Returns BarcodePicker

    The updated BarcodePicker object.

onProcessFrame

  • onProcessFrame(listener: function, once?: boolean): BarcodePicker
  • Add the listener function to the listeners array for the processFrame event, fired when a new frame is processed. This event is fired on every frame, independently from the number of recognized barcodes (can be none). 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.

    deprecated

    Use the on method instead.

    Parameters

    • listener: function

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

    • Default value once: boolean = false

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

    Returns BarcodePicker

    The updated BarcodePicker object.

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. If the library has already been loaded the listener is called immediately.

    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.

    deprecated

    Use the on method instead.

    Parameters

    • listener: function

      The listener function.

        • (): void
        • Returns void

    Returns BarcodePicker

    The updated BarcodePicker object.

onScan

  • 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.

    deprecated

    Use the on method instead.

    Parameters

    • listener: function

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

    • Default value once: boolean = false

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

    Returns BarcodePicker

    The updated BarcodePicker object.

onScanError

  • Add the listener function to the listeners array for the scanError 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.

    deprecated

    Use the on method instead.

    Parameters

    • listener: function

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

        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    • Default value once: boolean = false

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

    Returns BarcodePicker

    The updated BarcodePicker object.

onSubmitFrame

  • onSubmitFrame(listener: function, once?: boolean): BarcodePicker
  • Add the listener function to the listeners array for the submitFrame event, fired when a new frame is submitted to the engine to be processed. As the frame is not processed yet, the ScanResult.barcodes property will always be empty (no results yet).

    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.

    deprecated

    Use the on method instead.

    Parameters

    • listener: function

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

    • Default value once: boolean = 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.

    By default video from the camera is still shown, if the pauseCamera option is enabled the camera stream is paused (camera access is fully interrupted) and will be resumed when calling resumeScanning or accessCamera, possibly requesting user permissions if needed.

    In "single image mode" the input for submitting a picture is disabled.

    Parameters

    • Default value pauseCamera: boolean = false

      Whether to also pause the camera stream.

    Returns BarcodePicker

    The updated BarcodePicker object.

reassignOriginElement

  • reassignOriginElement(originElement: HTMLElement): BarcodePicker
  • Reassign the barcode picker to a different HTML element.

    All the barcode picker elements inside the current origin element will be moved to the new given one.

    If an invalid element is given, a NoOriginElementError error is thrown.

    Parameters

    • originElement: HTMLElement

      The HTMLElement into which all the necessary elements for the picker will be moved.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeAllListeners

  • Remove all listeners from the given event's listener array.

    Parameters

    • eventName: EventName

      The name of the event from which to remove all listeners.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeListener

  • removeListener(eventName: EventName, listener: ListenerFn): BarcodePicker
  • Remove the specified listener from the given event's listener array.

    Parameters

    • eventName: EventName

      The name of the event from which to remove the listener.

    • listener: ListenerFn

      The listener function to be removed.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeProcessFrameListener

  • Remove the specified listener from the processFrame event's listener array.

    deprecated

    Use the removeListener method instead.

    Parameters

    • listener: function

      The listener function to be removed.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeProcessFrameListeners

removeScanErrorListener

  • Remove the specified listener from the scanError event's listener array.

    deprecated

    Use the removeListener method instead.

    Parameters

    • listener: function

      The listener function to be removed.

        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    Returns BarcodePicker

    The updated BarcodePicker object.

removeScanErrorListeners

removeScanListener

  • Remove the specified listener from the scan event's listener array.

    deprecated

    Use the removeListener method instead.

    Parameters

    • listener: function

      The listener function to be removed.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeScanListeners

removeSubmitFrameListener

  • Remove the specified listener from the submitFrame event's listener array.

    deprecated

    Use the removeListener method instead.

    Parameters

    • listener: function

      The listener function to be removed.

    Returns BarcodePicker

    The updated BarcodePicker object.

removeSubmitFrameListeners

resumeScanning

  • Resume the recognition of codes in the input image.

    If the camera stream was stopped when calling pauseScanning, the camera stream is also resumed and user permissions are requested if needed to resume video input.

    In "single image mode" the input for submitting a picture is enabled.

    Returns Promise<BarcodePicker>

    The updated BarcodePicker object.

setActiveCamera

  • Select a camera to be used for video input, if no camera is passed, the default one is selected.

    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

    In "single image mode" this method has no effect.

    Parameters

    • Optional camera: Camera

      The new camera to be used, by default the automatically detected back camera is 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).

setCameraSwitcherEnabled

  • Show or hide a GUI button to switch between different cameras (when available).

    In "single image mode" this method has no effect.

    Parameters

    • enabled: boolean

      Whether to show a GUI button to switch between different cameras.

    Returns BarcodePicker

    The updated BarcodePicker object.

setGuiStyle

  • Set the GUI style for the picker.

    In "single image mode" this method has no effect.

    When the GUI style is set to laser or viewfinder, the GUI will flash on barcode recognition. Note that the GUI will flash if there's at least a barcode not rejected via ScanResult.rejectCode.

    Parameters

    • guiStyle: GuiStyle

      The new GUI style to be applied.

    Returns BarcodePicker

    The updated BarcodePicker object.

setLaserArea

  • Set the area of the laser displayed when the GUI style is set to laser (the laser will match the width and be vertically centered). Note that this functionality affects UI only and doesn't change the actual search area set via ScanSettings. If no area is passed, the default automatic size behaviour is set, where the laser will match the current area of the image in which barcodes are searched, controlled via the searchArea option in ScanSettings.

    Parameters

    • Optional area: SearchArea

      The new search area, by default the area will match the ScanSettings's searchArea.

    Returns BarcodePicker

    The updated BarcodePicker object.

setMirrorImageEnabled

  • Enable or disable camera video mirroring along the vertical axis. By default front cameras are automatically mirrored. This setting is applied per camera and the method has no effect if no camera is currently selected.

    In "single image mode" this method has no effect.

    Parameters

    • enabled: boolean

      Whether the camera video is mirrored along the vertical axis.

    Returns BarcodePicker

    The updated BarcodePicker object.

setPinchToZoomEnabled

  • Enable or disable camera zoom control via pinching gesture on the video (when available, only Chrome).

    In "single image mode" this method has no effect.

    Parameters

    • enabled: boolean

      Whether to enable camera zoom control via pinching gesture on the video.

    Returns BarcodePicker

    The updated BarcodePicker object.

setPlaySoundOnScanEnabled

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

    The sound is played if there's at least a barcode not rejected via ScanResult.rejectCode.

    Parameters

    • enabled: boolean

      Whether a sound should be played on barcode recognition.

    Returns BarcodePicker

    The updated BarcodePicker object.

setTapToFocusEnabled

  • Enable or disable manual camera focus when clicking/tapping on the video (when available, only Chrome).

    In "single image mode" this method has no effect.

    Parameters

    • enabled: boolean

      Whether to enable manual camera focus when clicking/tapping on the video.

    Returns BarcodePicker

    The updated BarcodePicker object.

setTargetScanningFPS

  • Set the target frames per second to be processed by the scanning engine.

    The final speed is limited by the camera framerate (usually 30 FPS) and the frame processing time of the device. By setting this to lower numbers devices can save power by performing less work during scanning operations, depending on device speed (faster devices can "sleep" for longer periods).

    In "single image mode" this method has no effect.

    Parameters

    • targetScanningFPS: number

      The target frames per second to be processed. Must be a number bigger than 0, by default set to 30.

    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).

    In "single image mode" this method has no effect.

    Parameters

    • enabled: boolean

      Whether the torch should be enabled or disabled.

    Returns BarcodePicker

    The updated BarcodePicker object.

setTorchToggleEnabled

  • Show or hide a GUI button to toggle device torch on/off (when available, only Chrome).

    In "single image mode" this method has no effect.

    Parameters

    • enabled: boolean

      Whether to show a GUI button to toggle device torch on/off.

    Returns BarcodePicker

    The updated BarcodePicker object.

setVibrateOnScanEnabled

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

    The vibration is triggered if there's at least a barcode not rejected via ScanResult.rejectCode.

    Parameters

    • enabled: boolean

      Whether the device should vibrate on barcode recognition.

    Returns BarcodePicker

    The updated BarcodePicker object.

setVideoFit

  • Set the fit type for the video element of the picker.

    If the "cover" type is selected the maximum available search area for barcode detection is (continuously) adjusted automatically according to the visible area of the picker.

    In "single image mode" this method has no effect.

    Parameters

    • objectFit: ObjectFit

      The new fit type to be applied.

    Returns BarcodePicker

    The updated BarcodePicker object.

setViewfinderArea

  • Set the area of the viewfinder displayed when the GUI style is set to viewfinder. Note that this functionality affects UI only and doesn't change the actual search area set via ScanSettings. If no area is passed, the default automatic size behaviour is set, where the viewfinder will match the current area of the image in which barcodes are searched, controlled via the searchArea option in ScanSettings.

    Parameters

    • Optional area: SearchArea

      The new search area, by default the area will match the ScanSettings's searchArea.

    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.

setZoom

  • Set the zoom level of the device (when available, only Chrome). Changing active camera or camera settings will cause the zoom to be reset.

    In "single image mode" this method has no effect.

    Parameters

    • zoomPercentage: number

      The percentage of the max zoom (between 0 and 1).

    Returns BarcodePicker

    The updated BarcodePicker object.

Static create

  • create(originElement: HTMLElement, __namedParameters?: object): Promise<BarcodePicker>
  • Create a BarcodePicker instance, creating the needed HTML in the given origin element. If the accessCamera option is enabled (active by default) and the picker is not in "single image mode", the available cameras are accessed and 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.

    The "single image mode" behaviour of the picker can be set up via the singleImageMode option, which accepts a configuration object of the form:

    {
      desktop: {
        always: false, allowFallback: true
      },
      mobile: {
        always: false, allowFallback: true
      }
    }

    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).
      • enablePinchToZoom: boolean
        Default = true
        Whether to control the zoom of the camera when doing a pinching gesture on the video (when available, only Chrome).
      • 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.
      • laserArea: undefined | SearchArea
        Default = undefined
        The area of the laser displayed when the GUI style is set to *laser* (the laser will match the width and be vertically centered), by default the area will match the current ScanSettings's *searchArea*.
      • playSoundOnScan: boolean
        Default = false
        Whether a sound is played on barcode recognition (iOS requires user input).
      • scanSettings: ScanSettings
        Default = new ScanSettings()
        The configuration object for scanning options to be applied to the scanner (all symbologies disabled by default).
      • scanner: undefined | Scanner
        Default = undefined
        The scanner object responsible for scanning via the external Scandit Engine library (a new scanner will be created and initialized if not provided).
      • scanningPaused: boolean
        Default = false
        Whether the picker starts in a paused scanning state.
      • targetScanningFPS: number
        Default = 30
        The target frames per second to be processed, the final speed is limited by the camera framerate (usually 30 FPS) and the frame processing time of the device. By setting this to lower numbers devices can save power by performing less work during scanning operations, depending on device speed (faster devices can "sleep" for longer periods). Must be a number bigger than 0.
      • vibrateOnScan: boolean
        Default = false
        Whether the device vibrates on barcode recognition (only Chrome & Firefox, requires user input).
      • videoFit: ObjectFit
        Default = ObjectFit.CONTAIN
        The fit type for the video element of the picker.
      • viewfinderArea: undefined | SearchArea
        Default = undefined
        The area of the viewfinder displayed when the GUI style is set to *viewfinder*, by default the area will match the current ScanSettings's *searchArea*.
      • visible: boolean
        Default = true
        Whether the picker starts in a visible state.
      • singleImageMode: object
        Default =  { desktop: { always: false, allowFallback: true }, mobile: { always: false, allowFallback: true } }
        Whether to provide a UI to pick/snap a single image from the camera instead of accessing and using the persistent video stream from a camera ("force"), or to allow to provide this as a fallback ("allowFallback") in case the necessary features for direct camera access are not provided by the OS/browser.
        • desktop: object
          • allowFallback: true
          • always: false
        • mobile: object
          • allowFallback: true
          • always: false

    Returns Promise<BarcodePicker>

    A promise resolving to the created ready BarcodePicker object.

Generated using TypeDoc