ionic 4 cameraPreview插件无需点击即可拍照

时间:2019-06-03 06:53:25

标签: cordova ionic-framework cordova-plugins

我正在将cordova CameraPreview插件与ionic4一起使用。它按我的需要显示,但它不等待水龙头拍照。它只是自动拍摄一张照片,而无需等待。

async openCamera(){

    const cameraPreviewOpts: CameraPreviewOptions = {
      x: 0,
      y: (window.screen.height - (window.screen.width*2/3) - 200),
      width: window.screen.width,
      height: (window.screen.width*2/3),
      camera: 'rear',
      tapPhoto: true,
      tapToFocus: true,
      previewDrag: false,
      toBack: false,
      alpha: 1
    }

    await this.cameraPreview.startCamera(cameraPreviewOpts)

      const pictureOpts: CameraPreviewPictureOptions = {
        quality: 25
      }

       this.presentToast('Tap on the image to capture it')
      // take a picture
      this.cameraPreview.takePicture(pictureOpts).then((imageData) => {
            this.cameraPreview.stopCamera();

      }, (err) => {
        console.log(err);
        alert('failed')
      });


  }

0 个答案:

没有答案