0

我使用 MediaPlugin 在 iOS 上录制视频。录制后,我使用 PHAsset.FetchAssets 获取录制视频的信息,但 PHAsset.Location 为空。

如果使用Camera APP录制,则可以获取PHAsset.Location。有人可以告诉我如何在 MediaPlugin 录制的视频的 PHAsset 中添加位置吗?非常感谢。

这是一些相关的代码。

    var file = await CrossMedia.Current.TakeVideoAsync(new Plugin.Media.Abstractions.StoreVideoOptions
    {
        Name = "video.mp4",
        Directory = "DefaultVideos",
        SaveToAlbum = true,
    });

...

    var fetchOptions = new PHFetchOptions();
    fetchOptions.SortDescriptors = new NSSortDescriptor[] { new NSSortDescriptor("creationDate", false) };
    PHFetchResult videosFetchResult = PHAsset.FetchAssets(PHAssetMediaType.Video, fetchOptions);

    foreach (PHAsset videoAsset in videosFetchResult)
    {
        if (videoAsset.Location != null)
        {
            videoItem.RecordPlace.Longitude = videoAsset.Location.Coordinate.Longitude;
            videoItem.RecordPlace.Latitude = videoAsset.Location.Coordinate.Latitude;
            videoItem.RecordPlaceName = "";
...
        }
    }
4

0 回答 0