Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

iOS - System.NullReferenceException while compressing video #608

Closed
andreiionita opened this issue Aug 28, 2018 · 0 comments
Closed

iOS - System.NullReferenceException while compressing video #608

andreiionita opened this issue Aug 28, 2018 · 0 comments

Comments

@andreiionita
Copy link

Version Number of Plugin: 4.0.1.5
Device Tested On: iPad Air
Simulator Tested On: iPad Air2
Version of VS: 7.5.2(build 40)
Version of Xamarin: Xamarin.Mac Version: 4.4.1.193
Versions of other things you are using:

  • Xamarin.iOS Version: 11.12.0.4
  • Xamarin Forms Version 3.0.0.482510
  • Permissions Plugin Version 3.0.0.12
  • Acr.UserDialogs Plugin Version 7.0.1

Steps to reproduce the Behavior

  1. Create a new forms project;
  2. Install plugins;
  3. Add a button that that will allow to select a video when clicked;
  4. Select a video;
  5. Tap "Use";
  6. While video is compressing, tap anywhere outside "select video" view;

Expected Behavior

  • video is being compressed;

Actual Behavior

  • app crashes;

###StackTrace
https://gist.github.com/andreiionita/47f5664ca3ae7aa461c20a0b750ecafb

Code snippet

`
async void Handle_Clicked(object sender, System.EventArgs e)
{
string media = await SelectVideo(this);
}

    public static async Task<string> SelectVideo(ContentPage contentPage)
    {
        PermissionStatus status = PermissionStatus.Unknown;
            status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.MediaLibrary);
        if (status != PermissionStatus.Granted)
        {
            if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.MediaLibrary))
                await UserDialogs.Instance.AlertAsync("Sharesafe Health requires your permission to access videos", "Need Permission");
            Dictionary<Permission, PermissionStatus> results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.MediaLibrary });
            status = results[Permission.MediaLibrary];
        }
        if (status == PermissionStatus.Granted)
            return await actuallySelectVideo(contentPage);
        else if (status != PermissionStatus.Unknown)
        {
            ConfirmConfig confirmConfig = new ConfirmConfig
            {
                Message = "This feature requires you to grant it MediaLibrary Permissions. To do this, Go to Settings, tap the Permissions link and select ON for the MediaLibrary Permission.",
                Title = "Storage Permission Denied",
                OkText = "Go to app Settings",
                CancelText = "Cancel"
            };
            confirmConfig.OnAction += (bool gotoSettings) =>
            {
                if (gotoSettings)
                    CrossPermissions.Current.OpenAppSettings();
            };
            UserDialogs.Instance.Confirm(confirmConfig);
        }
        return null;
    }
    private static async Task<string> actuallySelectVideo(ContentPage contentPage)
    {
        MediaFile file = null;
        string path = "";
        if (CrossMedia.Current.IsPickVideoSupported)
            file = await CrossMedia.Current.PickVideoAsync();
        else
            UserDialogs.Instance.Alert("Access to media declined", "Edit your phone's privacy settings to allow this feature.", "OK");
        if (file == null)
            return null;
        else
            return path;
    }

`

Screenshots

screen shot 2018-08-28 at 13 44 28

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants