A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Hello,
Welcome to our Microsoft Q&A platform!
For this, you can use Xam.Plugin.Media to achieve this, which is a simple cross platform plugin to take photos and video or pick them from a gallery from shared code.
And this library has a lot of legacy code that is extremely hard to maintain and update to support the latest OSes without a major re-write.
You can get image path as follows:
pickPhoto.Clicked += async (sender, args) =>
{
if (!CrossMedia.Current.IsPickPhotoSupported)
{
DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
return;
}
var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
});
if (file == null)
return;
System.Diagnostics.Debug.WriteLine("path1 = " + file.AlbumPath);
System.Diagnostics.Debug.WriteLine("path2 = " + file.Path);
image.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
});
};
For more details, you can check: https://github.com/jamesmontemagno/MediaPlugin .
And there is a sample included in above link, you can try yourself.
Best Regards,
Jessie Zhang
---
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.