diff --git a/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs b/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs index f12651c..cac09d4 100644 --- a/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs +++ b/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs @@ -28,6 +28,14 @@ public static void ReceiveBarcode(string barcodeText) BarcodeReaderInterop.OnBarcodeReceived(barcodeText); } + [JSInvokable] + public static void ReceiveError(object error) + { + // What to do with the knowledge that an error happened? + // Looking at current examples this might indicate issues with one of the decoders + // (namely BrowserQRCodeReader appears to throw errors occasionally...) + } + [JSInvokable] public static void ReceiveNotFound() { diff --git a/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js b/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js index a287b66..5646179 100644 --- a/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js +++ b/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js @@ -96,7 +96,6 @@ window.BlazorBarcodeScanner = { console.log("Starting decoding with " + videoConstraints); await this.codeReader.decodeFromConstraints({ video: videoConstraints }, video, (result, err) => { if (result) { - console.log(result); if (this.lastPictureDecodedFormat) { this.lastPictureDecoded = this.codeReader.captureCanvas.toDataURL(this.lastPictureDecodedFormat); } @@ -106,8 +105,7 @@ window.BlazorBarcodeScanner = { }); } if (err && !(err instanceof ZXing.NotFoundException)) { - console.error(err); - DotNet.invokeMethodAsync('BlazorBarcodeScanner.ZXing.JS', 'ReceiveBarcode', err) + DotNet.invokeMethodAsync('BlazorBarcodeScanner.ZXing.JS', 'ReceiveError', err) .then(message => { console.log(message); });