Barcode Capture Listener#

Defined under the namespace Scandit.Datacapture.Barcode

BarcodeCaptureListener#
interface BarcodeCaptureListener

Added in version 6.1.0

Delegate interface for traditional barcode capture.

didScan(barcodeCapture, session)#
didScan(barcodeCapture: BarcodeCapture,
        session: BarcodeCaptureSession): void

Added in version 6.1.0

Invoked whenever a code has been scanned. The newly scanned codes can be retrieved from BarcodeCaptureSession.newlyRecognizedBarcodes.

This callback will be blocking the further processing of frames, so you should return from it as quickly as possible. Therefore, if you need to perform a time-consuming operation, like querying a database or opening an URL encoded in the barcode data, consider moving it out of this callback, e.g. by using a timeout to let this function return before you do any more work. It is advised to disable the capture mode while you’re doing additional work and enabling it again once that work is done.

Sometimes, after receiving this callback, you may want to pause scanning or to stop scanning completely.

  • To pause scanning, but keep the camera (frame source) running, just set the barcode capture’s enabled property to false.

    captureMode.enabled = false
    
  • To stop scanning, you will need to both disable the capture mode and stop the frame source. While it’s possible to only stop the camera and keep the capture mode enabled, this may lead to additional scan events being delivered, which is typically not desired. The following lines of code show how to disable the capture mode and stop the frame source as well:

    // no more didScan callbacks will be invoked after this call.
    captureMode.enabled = false
    // asynchronously turn off the camera as quickly as possible.
    captureMode.context.frameSource.switchToDesiredState(Scandit.FrameSourceState.Off);
    
didUpdateSession(barcodeCapture, session)#
didUpdateSession(barcodeCapture: BarcodeCapture,
        session: BarcodeCaptureSession): void

Added in version 6.1.0

Invoked after a frame has been processed by barcode capture and the session has been updated. In contrast to didScan(), this method is invoked, regardless whether a code was scanned or not. If codes were recognized in this frame, this method is invoked after didScan().

This callback will be blocking the further processing of frames, so you should return from it as quickly as possible. Therefore, if you need to perform a time-consuming operation, like querying a database or opening an URL encoded in the barcode data, consider moving it out of this callback, e.g. by using a timeout to let this function return before you do any more work. It is advised to disable the capture mode while you’re doing additional work and enabling it again once that work is done.

See the documentation in didScan() for information on how to properly stop recognition of barcodes.