Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaPicker.Default.CapturePhotoAsync missing important option like SaveToAlbum, PhotoSize, CompressionQuality #11353

Open
cdavidyoung opened this issue Nov 14, 2022 · 13 comments
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info proposal/open
Milestone

Comments

@cdavidyoung
Copy link

Description

I am re-engineering my Xamarin app for Maui. I know the latter is still under development so I would like to request these features. In the meanwhile if there is a workaround for the SaveToAlbum option I would appreciate a pointer. Thanks.

Public API Changes

MediaPicker.Default.CapturePhotoAsync(new StoreCameraMediaOptions()
{
DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Rear,
SaveToAlbum = true,
PhotoSize = PhotoSize.Medium,
CompressionQuality = 92,
});

Intended Use-Case

The user can take a photo from within my app at which point I also record an audio snippet that corresponds with the moment the photo is taken. In addition to the app DB, it is important that the photo be stored in the user gallery so that they can easily access the photo later.

@Eilon Eilon added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label Nov 14, 2022
@jfversluis
Copy link
Member

I will be putting out a proposal for this soon! However, this won't be implemented until .NET 8.

In the meanwhile have a look at https://github.com/dimonovdd/Xamarin.MediaGallery which should have all this and supports .NET MAUI.

As for the implementation of this, are you missing anything that you wish the Xamarin MediaPicker had? Or things that should work differently? Anything of which you think: if there was a newer version I wish this would be better?

@jfversluis jfversluis added this to the Backlog milestone Nov 15, 2022
@ghost
Copy link

ghost commented Nov 15, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@cdavidyoung
Copy link
Author

cdavidyoung commented Nov 15, 2022 via email

@jfversluis
Copy link
Member

@cdavidyoung I think you're reading the description wrong. The author of MediaGallery is stating that other plugins don't seem to be maintained and lacking .NET MAUI support. This is the reason that he created MediaGallery.

MediaGallery, as far as I know, has everything that is in our MediaPicker and more.

@cdavidyoung
Copy link
Author

cdavidyoung commented Nov 16, 2022 via email

@cdavidyoung
Copy link
Author

cdavidyoung commented Nov 18, 2022 via email

@cdavidyoung
Copy link
Author

I can't get past the Android Required Setup. I get the following error. One problem is that there is no AndroidResource now in Maui and I have tried the other types or Resource but can't get by this.

Error APT2260 resource xml/file_paths (aka com.CatchAll:xml/file_paths) not found.

This error is likely caused by an issue with the AndroidManifest.xml file or an Android manifest generation attribute in a source code file. jiffyLog C:\Users\charl\source\repos\GitHub\jiffyLog\Platforms\Android\AndroidManifest.xml 1

@cdavidyoung
Copy link
Author

Any advice on getting past this error? The copy to album is literally the last feature I need to publish my Maui app on 4 platforms, although this feature is really only needed on Android and iPhone. I have considered delving into the Xamarin code to port this feature from there to Maui. Any advice on the feasibility of this?

@cdavidyoung
Copy link
Author

Well, with Gerald's encouragement I finally got https://github.com/dimonovdd/Xamarin.MediaGallery to work for my app. I started by cloning the repo and building the sample app, which works. It demonstrates that it is possible to copy files to the gallery.

Knowing that, I followed the README.md file closely. After installing the Xamarin.MediaGallery nuget and doing the things required in README.md for Android (iOS does not need any special initialization because I was already taking photos in my app) you basically add at the beginning of the file where you want to use this:

using NativeMedia;

Then make sure this is only used for iOS and Android. Note that I am using standard Maui code for taking the photos. I am only using this to copy the photo to the gallery. I may look into MediaGallery to take the photo as well if it allows a compression option.

         // MediaGallery only works for these platforms.
         if (   (DeviceInfo.Current.Platform == DevicePlatform.iOS)
             || (DeviceInfo.Current.Platform == DevicePlatform.Android))
         {
            MediaFileType type = MediaFileType.Image;
            await MediaGallery.SaveAsync(MediaFileType.Image, newFile);
         }

@moljac
Copy link
Contributor

moljac commented Feb 16, 2024

C:\Users\charl.nuget\packages\xamarin.google.guava.listenablefuture\1.0.0.9\buildTransitive\net6.0-android31.0....\jar\guava-listenablefuture.jar:com/google/common/util/concurrent/ListenableFuture.class: 1>MSBUILD : java.exe error JAVA0000: Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: C:\Users\charl.nuget\packages\xamarin.google.guava.listenablefuture\1.0.0.9\buildTransitive\net6.0-android31.0....\jar\guava-listenablefuture.jar:com/google/common/util/concurrent/ListenableFuture.class, obj\Debug\net7.0-android\lp\184\jl\libs\E0614835FEE16B6F.jar:com/google/common/util/concurrent/ListenableFuture.class 1>MSBUILD : java.exe error JAVA0000: Compilation failed

You are using old version of nuget

Explicitly add latest version of Xamarin.Google.Guava.ListenableFuture

<PackageReference Include="Xamarin.Google.Guava.ListenableFuture" Version="1.0.0.17" />

That should help.

And please report here if that helps. if not I will need list of PackageReferences.

@Saccomani
Copy link

there's any workaround?

@danbrannanavontus
Copy link

What's the score with this? The comments above said this was going to be implemented in .Net 8 however we're running .Net 8 and it's still not possible to set these properties. Just yet another bug in Maui which there seems to be no urgency to fix.

@erviss
Copy link

erviss commented Sep 10, 2024

We are forced to migrate from Xamarin to Maui since there is no longer support for new Android and iOS versions, I would have expected at least equal functionality to Xamarin instead Maui is years of development far away!
Xamarin support should be ended at least in 2030 given how Maui is evolving

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info proposal/open
Projects
None yet
Development

No branches or pull requests

7 participants