Cordova-plugin-qrscanner: pausePreview () - не работает - PullRequest
0 голосов
/ 17 ноября 2018

Я пытаюсь приостановить просмотр с помощью метода 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));

Заранее спасибо.

...