MediaPicker Not Working with Xamarin.Forms

kcswindowskcswindows USMember
edited May 2016 in Xamarin.Forms

I am new to xamarin.in my project open gallery for select image for this i have used IMediaPicker interface.my code as below:

    IMediaPicker mediaPicker;
    ImageSource imageSource;
    async void OnTapEntertainer(object sender, EventArgs args)
    {          
       await TakePicture();
    }

    private async Task TakePicture()
    {           
            mediaPicker = DependencyService.Get<IMediaPicker>();
            imageSource = null;
            var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
            {
                DefaultCamera = CameraDevice.Front,
                MaxPixelDimension = 400
            });
            imageSource = ImageSource.FromStream(() => mediaFile.Source);
            Imgmn.Source = imageSource;
    }

I got mediaPicker is null value in this code.Please help me to solve this issue. I have added capability required for perform function.

Answers

Sign In or Register to comment.