0
早上好,Xamarin.Io嵌入视频
我必须从我的资源中嵌入一个视频在UIView。 因此,我首先将我的视频添加到我的资源文件夹中,并将其构建操作置于“内容”。 我的视频采用MP4格式。
然后我创建了这个函数,这是在ViewDidLoad调用。
void Video()
{
string fileName = "Resources/Movies/menu.mp4";
string locallUrl = Path.Combine(NSBundle.MainBundle.BundlePath, fileName);
NSUrl url = NSUrl.FromFilename("menu.mp4");
_player = new MPMoviePlayerController(url);
_player.View.Frame = VideoView.Bounds;
VideoView.AddSubview(_player.View);
_player.ControlStyle = MPMovieControlStyle.None;
_player.PrepareToPlay();
}
然后我在ViewDidAppear中调用_player.Play()。
但没有发生。
我想我错过了什么,但我不知道是什么。
感谢的提前,
问候,
安东尼
你不需要通过文件名中的'Resources /',尝试添加它将工作'电影/ menu.mp4' –
看看这个链接https://developer.xamarin.com/recipes/ios/ media/video_and_photos/play_a_video_using_mpmovieplayercontroller/ –
如果我从路径中删除了'Ressources /',它不起作用。我已经看过这个链接。 – CaptainCook