I am looking to use camera2 for image and video capture. I found that for image capture I can use the method .setFlashMode(flash_type)
but the video capture object does not have this.
CameraManager camManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
String cameraId = null;
try {
cameraId = camManager.getCameraIdList()[0];
camManager.setTorchMode(cameraId, true); //Turn ON
} catch (CameraAccessException e) {
e.printStackTrace();
}
I have tried using this method where I would turn on the flash before the video capture but was hit with an error which was due to the camera already being in use.
So, I am wondering, is this even possible in androidx yet?
I found a solution over at the issue tracker for androidx.camera which seems to work.
if (flash_type == ImageCapture.FLASH_MODE_ON)
videoCapture.getCamera().getCameraControl().enableTorch(true);
Any then do the opposite when stopping the video capture.