Options
All
  • Public
  • Public/Protected
  • All
Menu

cmbWeb

Index

Type Aliases

MyCallback: ((result: object) => void)

Type declaration

    • (result: object): void
    • A callback method example for custom handling of the scan result.

      var myCallback = function(result) {

      if (result.type == "Error") console.log(result.errorDetails);
      else if (result.type == "Cancel") console.log("No Barcode.");
      else if (result.type == "NoResult") console.log("No Barcode.");

      else if (result.type == "Multicode")
      {
      let resultCodes_string = "";
      let foundCodes = result.count;
      for (let i = 0; i < foundCodes; i++)
      {
      resultCodes_string += result.codes[i].type + '\n' + result.codes[i].code + '\n';

      }
      mwbScanner.beep();
      console.log(result.type + '\n\n' + resultCodes_string);
      }
      else
      {
      mwbScanner.beep();
      console.log(result.type + '\n' + result.code);

      //mwbScanner.resumeScanning(); //if using !MWBcloseScannerOnDecode
      }
      }

      Parameters

      • result: object

        Result properties:

        • if multiple barcode detection on a single image / frame is enabled and at least one barcode is detected:

          • type         - string "Multicode"
          • code        - empty string
          • count       - the number of detected barcodes
          • codes       - array of detected barcodes in the result format below
        • if using single code (or result.codes array elements in case of using multicode):

          • type         - type of barcode detected
          • code        - string representation of barcode result
          • parsedCode    - string json representation of parsed barcode result (if any)
          • bytes       - bytes array of raw barcode result
          • isGS1       - (boolean) barcode is GS1 compliant
          • location        - object that contains rectangle points p1,p2,p3,p4 with the corresponding x,y
          • imageWidth    - width of the scanned image
          • imageHeight     - height of the scanned image
          • modulesCountX   - number of modules horizontally
          • modulesCountY   - number of modules vertically
          • moduleSizeX     - width of a module
          • moduleSizeY     - height of a module
          • ppm        - pixels per module
        • additional optional fields (available only if enabled):

        Above fields and associated values are typical when the scanner successfully detects barcode(s). This is not always the case; the following values are also possible:

        • if a camera-related error has occured after calling startScanning:
          • type         - string "Error"
          • code        - user-friendly error description
          • errorDetails     - an object containing error properties and various explanations
            • name        - error name
            • message        - error message
            • mozilla        - explanation from mozilla
            • userFriendly     - user-friendly explanation
            • mostLikelyCause   - most likely cause of the error
        • if a previously started scanning is canceled by means of closeScanner or a timeout:

          • type         - string "Cancel"
        • if no barcode has been found or detected when using scanImage or scanFrame:

          • type         - string "NoResult"

      Returns void

Functions

  • myScannerReadyEventListener(e: CustomEvent<any>): void
  • A scannerModuleLoaded event listener example.

    ⚡ A "scannerModuleLoaded" event is triggered once all the modules have loaded after loading the page. After this event the scanner is ready and exposed methods from the mwbScanner object can be invoked.

    The event is fired under document, and so, the event listener is to be added to it.

    document.addEventListener("scannerModuleLoaded", function(e) {
    console.log(e.detail); //Prints "Scanner is ready."

    //can use mwbScanner.* methods now
    });

    Note: Attempting to use the API, for example making the scan call (e.g. mwbScanner.startScanning()) before the scanner is ready (i.e. scannerModuleLoaded event has not fired yet) would result in an error.

    Parameters

    • e: CustomEvent<any>

      The event interface. Contains the read-only detail property.

      • e.detail      Contains "Scanner is ready." string value or license status string value.

      Possible values:

      • "Scanner is ready."
      • "Invalid domain."
      • "Invalid license."
      • "Expired license."

      Note: Regardless of string value the scanner is ready once the scannerModuleLoaded event has fired (results will be masked if not licensed).

    Returns void

  • myCameraReadyEventListener(e: CustomEvent<any>): void
  • A cameraReady event listener example.

    ⚡ A "cameraReady" event is triggered when the camera is fully initialized after calling the startScanning method. After this event the cameraPreview is shown.

    The event is fired under document, and so, the event listener is to be added to it.

    document.addEventListener("cameraReady", function(e) {
    console.log(e.detail); //Prints "Camera is ready."
    });

    Parameters

    • e: CustomEvent<any>

      The event interface. Contains the read-only detail property.

      • e.detail      Contains "Camera is ready." string value.

    Returns void

  • myCameraPreviewClosedEventListener(e: CustomEvent<any>): void
  • A cameraPreviewClosed event listener example.

    ⚡ A "cameraPreviewClosed" event is triggered when the camera preview is removed from the document body or container element after calling the closeScanner method.

    The event is fired under document, and so, the event listener is to be added to it.

    document.addEventListener("cameraPreviewClosed", function(e) {
    console.log(e.detail); //Prints "Camera preview closed."
    });

    Parameters

    • e: CustomEvent<any>

      The event interface. Contains the read-only detail property.

      • e.detail      Contains "Camera preview closed." string value.

    Returns void

Generated using TypeDoc