此代码在非故事板环境中工作,但仅在故事板 ViewController 上运行时显示黑屏。不知道会有什么不同。欢迎提出建议
public partial class videoVC : UIViewController
{
MPMoviePlayerController mp = new MPMoviePlayerController();
public videoVC (IntPtr handle) : base (handle)
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.buttonPlay.TouchUpInside += delegate {
try{
mp = new MPMoviePlayerController(NSUrl.FromFilename("videos/file.m4v"));
mp.AllowsAirPlay = true;
this.View.AddSubview(mp.View);
mp.SetFullscreen(true,true);
mp.PrepareToPlay();
mp.Play();
}catch{
Console.WriteLine("There was a problem playing back Video");
}
};