1

Right now I am creating a Xamarin application and I am using the camera to login. The application is working fine as below:

    var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { });

The above method uses the Camera API and builds the Camera frame and Button as below:

enter image description here

I wanted to fire click event of the camera just after 10 seconds automatically. Kindly let me know the Event Name, which will be fired, and how will it fire?

Thanks

Andrew Chisholm
  • 6,362
  • 2
  • 22
  • 41
Sourabh Somani
  • 2,138
  • 1
  • 13
  • 27

1 Answers1

1

There is no such event in MediaPlugin.

There are 2 solutions how to approach your requirements.

The first one is to run the delay whether the photo is taken or not.

var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { });
await Task.Delay(10000);
if(photo != null)
{ 
    //photo was taken
}
else
{
    //camera was canceled
}

More cleaner solution is to use timer and once timer expires you can execute your code.

The second one is more harder to implement. You need to write platform specific code for Android and for iOS.

It means in YourProjectName.Android project you have to implement broadcastreceiver to listen camera button click.

The same for YourProjectName.iOS. Here's a link!

Jan Nepraš
  • 794
  • 1
  • 7
  • 29