[英]Videofile sharing issue with Xamarin.Essentials
我正在使用下一個代碼:
try
{
await Share.RequestAsync(new ShareFileRequest
{
Title = filename,
File = new ShareFile(filename),
PresentationSourceBounds = new System.Drawing.Rectangle(0, 0, 1, 1)
});
}
catch (Exception)
{
}
現在我正在嘗試共享不同的文件類型。 ASCII 和二進制文件可以毫無問題地共享,但是當我嘗試共享視頻文件時,例如/var/mobile/Containers/Data/Application/xxxxx/Library/Caches/app_2022_06_14_17_58_13.mp4
,Dropbox 顯示一條消息Couldn't load file. Sorry, an error occured
Couldn't load file. Sorry, an error occured
,其他目的地如Save to files
不顯示錯誤但文件未寫入。
我嘗試使用File = new ShareFile(filename, "video/mp4"),
或使用assets-library://asset/asset.mp4?id=xxxxx&ext=mp4
類的庫資產文件,但這並不'幫助。
我用的是Xamarin.Essentials 1.7.3,iOS版本是15.5
可能是什么原因? 先感謝您。
您需要正確設置PresentationSourceBounds
。在我的場景中,我將mp4
文件放在 Resources 文件夾中。請參閱我的示例代碼以供參考:
使用Xamarin.Essentials 1.7.0,iOS版本為15.5
private async void Button_Clicked(object sender, EventArgs e)
{
var fn = "sample-5s.mp4";
var bounds = ((Button)sender).Bounds;
await Share.RequestAsync(new ShareFileRequest
{
Title = "My title",
File = new ShareFile(fn, "video/mp4"),
PresentationSourceBounds = new System.Drawing.Rectangle((int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height)
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.