0

I have created a new Xamarin Forms App with the media plugin (via NuGet on VS 2019) and used a part of the samples-code to take photos. The images are created correctly. Problem is the code after PickPhotoAsync is never executed (Same with the complete sample from github):

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;

        image.Source = ImageSource.FromStream(() =>
        {
          var stream = file.GetStream();
          file.Dispose();
          return stream;
        });
      };

How can I solve this? Thanks

stefanD
  • 1
  • 1
  • What's your XF version,i test your codes in version 4.8.0.1364 and 4.8.0.1534,they both work. – Leo Zhu Oct 14 '20 at 02:20
  • It is XF 4.8.0.1534, I am developing on Samsung Galaxy Tab SM-T585 – stefanD Oct 14 '20 at 06:18
  • Did you try to run it on other devices ? – Leo Zhu Oct 14 '20 at 08:31
  • I tried to run the sample on a Huawei Media Pad, but the App crashes imediatly. I did this with current and older version of Xamarin Forms - result is the same. – stefanD Oct 14 '20 at 16:02
  • It's weird.It works on my side,is there any error message ? – Leo Zhu Oct 15 '20 at 08:46
  • Thank you for your interest in this issue. There no other messages. Now I will setup a new project again, paste the samples code into this class and keep you informed about the results. – stefanD Oct 15 '20 at 09:02
  • Ok,you could try it. – Leo Zhu Oct 16 '20 at 01:13
  • I give up: After creating a new Project it is still the same: none of the awaited functions ever returns ( CrossMedia.Current.PickPhotoAsync, CrossMedia.Current.TakePhotoAsync). – stefanD Oct 20 '20 at 10:05
  • On a different device an error comes up: It could be solved like described in [42516126](https://stackoverflow.com/questions/42516126/fileprovider-illegalargumentexception-failed-to-find-configured-root). With this alternative file_paths.xml everything works fine. – stefanD Oct 20 '20 at 15:46
  • You could try to report it to the github of the plugin. – Leo Zhu Oct 21 '20 at 07:35
  • Your are right, I will try to do so. – stefanD Oct 22 '20 at 08:03
  • Please check (https://github.com/jamesmontemagno/MediaPlugin/issues/884) – stefanD Oct 22 '20 at 10:01
  • Yes,i'll keep an eye on it. – Leo Zhu Oct 23 '20 at 07:54

0 Answers0