Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Taking a picture using Xam.Plugin.Media

$
0
0

Anyone with helpful hints on using the plugin in? When I call TakePhotoAsync I get a black screen and the app (as best as I can tell) hangs. I have to kill it at that point. My current iteration of code to try and get it to work is below. Any thoughts or pointers on gotchas would be appreciated.

        private async Task<ImageSource> TakeThePhoto()
        {
            await Plugin.Media.CrossMedia.Current.Initialize();
            ImageSource newphoto = null;
            Plugin.Media.Abstractions.MediaFile photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new            Plugin.Media.Abstractions.StoreCameraMediaOptions { });

            if (photo != null)
            {
                return ImageSource.FromStream(() => { return photo.GetStream(); });
            }

            return newphoto;
        }

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>