[英]Plugin.MediaManager.Forms: Video will not play from Xamarin.Forms App Data Directory
I'm trying to play a video on a Xamarin app using the Plugin.MediaManager.Forms nuget package.我正在尝试使用plugin.mediamanager.z64502531912981CAE81CAE88A32A66666666666666666666662BBEFE72BFEE72BFEE72BFEERENEM我尝试使用Z1B4419ABC4358B41D0CA50CA5077A63908Z应用程序播放视频。 The video is stored in the Xamarin App Data Directory so try to play the video by building the path to the folder with the filename.
视频存储在 Xamarin 应用程序数据目录中,因此请尝试通过构建具有文件名的文件夹的路径来播放视频。
var path = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, filename);
await CrossMediaManager.Current.Play(path);
Unfortunately I just get a blank screen when I call Play(path)
.不幸的是,当我调用
Play(path)
时,我只是得到一个空白屏幕。
I've also tried using FileInfo however I still just get a blank screen.我也尝试过使用 FileInfo 但是我仍然只是得到一个空白屏幕。
var path = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, filename);
FileInfo fileInfo = new FileInfo(path);
await CrossMediaManager.Current.Play(fileInfo);
I've tested on both Android, UWP & iOS platforms and see the same result.我已经在 Android、UWP 和 iOS 平台上进行了测试,并看到了相同的结果。
According to your description, the Xamarin.Essentials.FileSystem.AppDataDirectory path is /data/user/0/Package name/files/ , I add one.mp4 file in files folder, then the.mp4 video play successfully.根据您的描述, Xamarin.Essentials.FileSystem.AppDataDirectory 路径是/data/user/0/Package name/files/ ,我在文件夹中添加一个.mp4文件,然后.mp4视频播放成功。
So please confirm that wheather you have mp4 file.因此,请确认您是否有 mp4 文件。
<StackLayout>
<Button
x:Name="btnplay"
Clicked="btnplay_Clicked"
Text="play video" />
<video:VideoView HeightRequest="300" WidthRequest="200" />
</StackLayout>
private async void btnplay_Clicked(object sender, EventArgs e)
{
string filename = "minions.mp4";
var path = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, filename);
await CrossMediaManager.Current.Play(path);
}
You can see that there is one minions.mp4 file in files folder, then path is /data/user/0/demo.demo3/files/minions.mp4可以看到files文件夹中有一个minions.mp4文件,路径为/data/user/0/demo.demo3/files/minions.mp4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.