0

I'm adjusting the Java of a Cordova plugin which records video fine, but the client has requested to force the torch on, but what I have attempted isn't working, if someone can steer me in the right direction:

private void captureVideo(int duration, boolean highquality, boolean frontcamera) {
    Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
    String videoUri = getVideoContentUriFromFilePath(this.cordova.getActivity(), getTempDirectoryPath());
    intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);

    intent.putExtra("android.intent.extra.videoQuality", 0);

    // Added this line
    intent.putExtra("android.intent.extra.FLASH_MODE_ON", 1);

    if (Build.VERSION.SDK_INT > 7) {
      intent.putExtra("android.intent.extra.durationLimit", duration);
    }

    this.cordova.startActivityForResult(this, intent, CAPTURE_VIDEO);
  }
Grant
  • 5,709
  • 2
  • 38
  • 50
  • Seems that the FLASH_MODE_ON is not always handled, it may depend on vensor's camera app, see https://stackoverflow.com/a/19670928/1028256. AFAIK Cordova can have native plugins, you may try to use Linux APIs to control flashlight. One is /sys/class/leds in `sysfs` but you may need root permissions for that – Mixaz Nov 23 '22 at 13:46

0 Answers0