nstudio / nativescript-camera-plus

MIT License
79 stars 50 forks source link

question - Torch, not flash #139

Open arturikoX opened 3 years ago

arturikoX commented 3 years ago

Hi, I managed to make it torch rather then flash on android, Anyone knows how to make it work on ios ?

Thanks

Bezlepkin commented 3 years ago

Same question.

nampil commented 1 year ago

@arturikoX Hi, Wonder how you managed to make it torch rather then flash on android. Can you give me a hint on that please?

Bezlepkin commented 11 months ago

@nampil I can build the plugin, I have it working and put it on npm

Bezlepkin commented 11 months ago

Or you can put it locally in the plugins folder. I'll send you the code you need to be replaced.

nampil commented 11 months ago

Or you can put it locally in the plugins folder. I'll send you the code you need to be replaced.

Thanks, that will be great!

Bezlepkin commented 11 months ago

@nampil

you need to replace the toggleFlash method in index.android.ts with:

public toggleFlash(mode?: string) {
    if (this._camera) {
        if (this._camera.getFlashMode() === fancycamera.CameraFlashMode.OFF) {
        if (mode === 'torch') {
            this._camera.setFlashMode(fancycamera.CameraFlashMode.TORCH);
        } else {
            this._camera.setFlashMode(fancycamera.CameraFlashMode.ON);
        }
    } else {
        this._camera.setFlashMode(fancycamera.CameraFlashMode.OFF);
    }
    }
}

and when calling the method toggleFlash pass 'torch' prop

nampil commented 11 months ago

@nampil

you need to replace the toggleFlash method in index.android.ts with:

public toggleFlash(mode?: string) {
    if (this._camera) {
        if (this._camera.getFlashMode() === fancycamera.CameraFlashMode.OFF) {
      if (mode === 'torch') {
          this._camera.setFlashMode(fancycamera.CameraFlashMode.TORCH);
      } else {
          this._camera.setFlashMode(fancycamera.CameraFlashMode.ON);
      }
  } else {
      this._camera.setFlashMode(fancycamera.CameraFlashMode.OFF);
  }
    }
}

and when calling the method toggleFlash pass 'torch' prop

Thanks @Bezlepkin