I had this working at one point but unable to get to a working state again.
My below code is always returning null and for the life of me I can't figure out why.
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Plugin.Media;
private async void UploadPhoto_Clicked(object sender, EventArgs e)
{
await CrossMedia.Current.Initialize();
var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
{
CompressionQuality = 50,
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Large
});
if (file == null)
return;
db.uploadBlob(System.IO.Path.GetFileName(file.Path), (System.IO.FileStream)file.GetStream(), "photos");
await DisplayAlert("Success", "Photo Uploaded :-)", "OK");
}
I have added the below into my MainActivity
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
This is also happening for the other CrossMedia calls such as PickPhotoAsync, TakeVideoAsync and PickVideoAsync. I have Version 2.6.2 of Plugin.Media installed.
Thanks in Advance
Luke