我尝试使用下面的代码块将视频保存到图库,之后将此视频作为字节数组。我无法理解Library.AssetForUrl()部分是如何工作的。如何从中获取字节数组?
var Library = new ALAssetsLibrary();
albumSave = await Library.WriteVideoToSavedPhotosAlbumAsync(outputFileUrl);
Library.AssetForUrl (assetUrl, delegate(ALAsset asset) {
long size = asset.DefaultRepresentation.Size;
Console.WriteLine("Filename: " + asset.DefaultRepresentation.Filename);
byte[] imgData = new byte[size];
NSError nsError;
IntPtr buffer = Marshal.AllocHGlobal(imgData.Length);
asset.DefaultRepresentation.GetBytes(buffer, 0, (uint)size, out nsError);
Console.WriteLine(nsError);
Marshal.Copy(buffer, imgData, 0, imgData.Length);
},
(NSError err)=>
{
Console.WriteLine(err);
}