Result properties:
if multiple barcode detection on a single image / frame is enabled and at least one barcode is detected:
if using single code (or result.codes array elements in case of using multicode):
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 previously started scanning is canceled by means of closeScanner or a timeout:
if no barcode has been found or detected when using scanImage or scanFrame:
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.
The event interface. Contains the read-only detail property.
Possible values:
Note: Regardless of string value the scanner is ready once the scannerModuleLoaded event has fired (results will be masked if not licensed).
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."
});
The event interface. Contains the read-only detail property.
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."
});
The event interface. Contains the read-only detail property.
Generated using TypeDoc
A callback method example for custom handling of the scan result.