locked
How to use PHImageManager.DefaultManager.RequestAvAsset correctly? AvAsset is always null RRS feed

  • Question

  • User395545 posted

    asset is not null but avAsset always comes up as null. That's why I can't get video url. How can I fix this?

    var vOptions = new PHVideoRequestOptions(); vOptions.NetworkAccessAllowed = true; vOptions.Version = PHVideoRequestOptionsVersion.Original; vOptions.DeliveryMode = PHVideoRequestOptionsDeliveryMode.FastFormat;

    PHImageManager.DefaultManager.RequestAvAsset(asset, vOptions, (avAsset, audioMix, vInfo) => { if (avAsset != null) { videoUrl = ((AVFoundation.AVUrlAsset)avAsset).Url.Path; } }); await Task.Delay(5000);

    Wednesday, December 9, 2020 5:42 AM

All replies

  • User369978 posted

    It seems this issue only happens when you're trying to access image on iCloud .

    Try to Enable NetworkAccessAllowed and set version as Original on PHVideoRequestOptions .

    Refer to

    https://github.com/1and2papa/CTAssetsPickerController/issues/141 https://stackoverflow.com/questions/55488998/how-to-fix-empty-asset-issue-with-phimagemanager-in-assetspickercontroller-ios https://stackoverflow.com/questions/42552633/phimagemanager-requestavassetforvideo-getting-nil-from-second-time


    Xamarin forums are migrating to a new home on Microsoft Q&A! We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A! For more information, please refer to this sticky post.

    Wednesday, December 9, 2020 7:03 AM
  • User395545 posted

    @ColeX I checked the links and tried but the result did not change.

    Wednesday, December 9, 2020 10:05 AM
  • User369978 posted

    Try to get the result using gcd ,refer to https://stackoverflow.com/questions/33402017/requestexportsessionforvideo-null-error/33909949#33909949 .

    ``` PHImageManager.DefaultManager.RequestAvAsset(asset, vOptions, (avAsset, audioMix, vInfo) => {

                DispatchQueue.MainQueue.DispatchAsync(() => {
    
                    //here get avAsset
                });
    
            });
    

    ```

    Monday, December 14, 2020 8:32 AM