From ccdeb435e76b8194f7ed7d7a2977b36c278ea77d Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Fri, 20 Sep 2024 14:46:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=9E=E7=BB=AD=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E6=96=B9=E6=B3=95=EF=BC=8C=E4=B8=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=9A=82=E5=81=9C=E6=89=AB=E7=A0=81=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=B5=81=E5=86=8D=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- ohos/src/main/ets/MobileScannerPlugin.ets | 38 ++++++++++------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/ohos/src/main/ets/MobileScannerPlugin.ets b/ohos/src/main/ets/MobileScannerPlugin.ets index 69fe744..50b26a4 100644 --- a/ohos/src/main/ets/MobileScannerPlugin.ets +++ b/ohos/src/main/ets/MobileScannerPlugin.ets @@ -282,6 +282,9 @@ export class MobileScannerPlugin implements FlutterPlugin, MethodCallHandler, Ab } }); this.callback(_r, this.imageBuffer, this.cameraWidth, this.cameraHeight) + setTimeout(() => { + customScan.rescan(); + }, 1000) } // 返回相机帧的回调 private frameCallback: AsyncCallback = @@ -446,27 +449,20 @@ export class MobileScannerPlugin implements FlutterPlugin, MethodCallHandler, Ab } callback(barcodes: Barcode[], image: Uint8Array | null, width: number, height: number) { - // 需要先暂停后才能继续识别 - customScan.stop().then(() => { - if (image) { - this.publishEvent({ - "name": "barcode", - "data": barcodes, - "image": image, - "width": width, - "height": height - }) - } else { - this.publishEvent({ - "name": "barcode", - "data": barcodes - }) - } - // 连续识别 - setTimeout(() => { - this.startScan() - }, 1000) - }) + if (image) { + this.publishEvent({ + "name": "barcode", + "data": barcodes, + "image": image, + "width": width, + "height": height + }) + } else { + this.publishEvent({ + "name": "barcode", + "data": barcodes + }) + } } private isBarcodeInScanWindow(barcode: Barcode): boolean { -- Gitee