Closed bnk120 closed 5 years ago
I found solution by my own. Below working code:
private bool isFlashLight = false;
private void TurnFlashLight(object sender, EventArgs e)
{
if (!isFlashLight)
{
aparat.UpdateParameters(TurnOnFlash());
isFlashLight = true;
}
else
{
aparat.UpdateParameters(TurnOffFlash());
isFlashLight = false;
}
}
private UpdateRequest TurnOnFlash()
{
return new UpdateRequest.Builder()
.Flash(FlashSelectors.Torch())
.FocusMode(FocusModeSelectors.ContinuousFocus()) //you can use other focus selector
.Build();
}
private UpdateRequest TurnOffFlash()
{
return new UpdateRequest.Builder()
.Flash(FlashSelectors.Off())
.FocusMode(FocusModeSelectors.ContinuousFocus()) //you can use other focus selector
.Build();
}
Hi, I would like to turn on/off flashlight manually? How can i achieve that?
What are you trying to achieve or the steps to reproduce?
I have a button on my View with above function attached to Click event:
At runtime i've got this exception:
How did you initialize FA?
What did you expect?
Expect that i can turn flashlight ON when i click button without taking photo and turn flashlight OFF when click again button.