i am new to xamarin forms. now 'm developing a sample application for making a Torch. i got a nuget for On/Off the flash light. https://github.com/kphillpotts/Xamarin.Plugins/tree/master/Lamp . but i like to control the intensity of the flash light. i tried to use the native code but failed to do it. i search the google but cant find it .is there any way i can make it for achieving it.
Thank you in advance
I don't know a plugin that implements it. But you can easily extend the lamp plugin.
You could extend the interface ILamp like
public interface ILamp
{
///....
void TurnOn(float intensity);
}
then implement it by copying the TurnOn
functionality
iOS
public void TurnOn(float intensity)
{
var captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video);
if (captureDevice == null)
{
Debug.WriteLine("No captureDevice - this won't work on the simulator, try a physical device");
return;
}
NSError error = null;
captureDevice.LockForConfiguration(out error);
if (error != null)
{
Debug.WriteLine(error);
captureDevice.UnlockForConfiguration();
return;
}
else
{
if (captureDevice.TorchMode != AVCaptureTorchMode.On)
{
captureDevice.TorchMode = AVCaptureTorchMode.On;
NSError err;
captureDevice.SetTorchModeLevel(intensity, out err); // add this line
}
captureDevice.UnlockForConfiguration();
}
}
On Android I'm not sure if there is a API to control it. I can't find one. If there is one, just proceed like on iOS.
If the platform has no API, just implement TurnOn(float intensity)
like
public void TurnOn(float intensity)
{
TurnOn();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.