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();
});

//frameSize - is actual width and height of camera frame used for decoding
DSScanner.addEventListener('onScannerReady', function (frameSize) {
	console.log('HTML onScannerReady|'+frameSize.width + '|'+frameSize.height);
	document.getElementById('spinner').style.display = 'none';
	DSScanner.StartScanner();
});




Event that occurs after the scanner is destroyed (Destroy method), and fully free resources.

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




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 and 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);
});




Event fired by DecodeImage method when image is a decoded. The event receives the same parameter as onBarcode.

Example
DSScanner.addEventListener('onImageDecoded', function (barcodeResult) {
	console.log('image decoded');
});