Cordova-plugin-qrscanner:pausePreview()-不起作用

时间:2018-11-16 21:16:37

标签: ionic3 cordova-plugins

当扫描仪没有运气时,我尝试使用pausePreview()方法暂停预览。如何修复下面的代码以在扫描条形码时“冻结”预览?

在我的代码下面:

    // Optionally request the permission early
    this.qrScanner.prepare()
      .then((status: QRScannerStatus) => {
         if (status.authorized) {
           // camera permission was granted
           window.document.querySelector('ion-app').classList.add('transparentBody');
           this.qrScanner.show();
           this.qrScanner.enableLight();

           // start scanning
           let scanSub = this.qrScanner.scan().subscribe((text: string) => {
             console.log('Scanned something', text);
             this.scannedData = text;
             this.qrScanner.pausePreview();
             scanSub.unsubscribe(); // stop scanning
             this.qrScanner.hide(); // hide camera preview

             // reverse transparency of the page
             window.document.querySelector('ion-app').classList.remove('transparentBody');
           });

         } else if (status.denied) {
           // camera permission was permanently denied
           // you must use QRScanner.openSettings() method to guide the user to the settings page
           // then they can grant the permission from there
         } else {
           // permission was denied, but not permanently. You can ask for permission again at a later time.
         }
      })
      .catch((e: any) => console.log('Error is', e));

谢谢。

0 个答案:

没有答案