DSScanner Events


Event that occurs after the scanner is created (Create method), initialized and ready to be used.

Example
DSScanner.addEventListener('onScannerReady', function () {
	console.log('HTML onScannerReady');
	document.getElementById('spinner').style.display = 'none';
	DSScanner.StartScanner();
});




Event fired when there is a decoded barcode.
barcodeResult is array with barcodes.

Example
DSScanner.addEventListener('onBarcode', onBarcodeReady);
//...

function onBarcodeReady (barcodeResult) {
    var barDataEl = document.getElementById('status');

	for (var i = 0; i < barcodeResult.length; ++i) {
	        var sBarcode = DSScanner.bin2String(barcodeResult[i].data);
	        var sPoints = "";
	        for (var j = 0; j < 4; j++)
	            sPoints += "(" + barcodeResult[i].points[j].x + ", " + barcodeResult[i].points[j].y + "),";

	        barDataEl.innerHTML = barcodeResult[i].type + ": " + sBarcode + "|" + sPoints;
	        console.log(barDataEl.innerHTML);
    }
};



Fired when WebAssembly loaded и initialized.

Example
DSScanner.addEventListener('onInitialized', function () {
	console.log('onInitialized');
});




Event when the scanner started decoding.

Example
DSScanner.addEventListener('onScannerStarted', function () {
	console.log('onScannerStarted');
});
Note
SDK fires this event when scanner has been started to decode barcodes. Usually it fired after StartScanner method.




Event when the scanner stopped decoding.

Example
DSScanner.addEventListener('onScannerStopped', function () {
	console.log('onScannerStopped');
});




Any errors that occur.

Example
DSScanner.addEventListener('onError', function (err) {
	console.log(err.name + '-' + err.message);
});