我正在处理一个 xamarin.forms
的共享项目。我在设置视频作为启动画面时遇到了问题。我从这里得到了参考。
我遇到的问题是视频播放器被初始化并执行其过程,在此期间,AppDelegate代码首先返回。所以视频没有显示出来,但声音是有的。我是否漏掉了什么?
在这里,我合并了示例中的VideoController
和VideoViewController
。我只使用了VideoViewController
,并在SetMoviePlayer()
函数中引用我的资源文件夹中的视频。
我尝试过的代码:
AppDelegate.cs
[Register("AppDelegate")]
public partial class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override UIWindow Window { get; set; }
VideoViewController control = new VideoViewController();
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
try
{
Window = new UIWindow(UIScreen.MainScreen.Bounds);
Window.RootViewController = control;
//global::Xamarin.Forms.Forms.Init();
//LoadApplication(new App());
//control.VideoCompletionEvent += Control_VideoCompletionEvent; // Tried to invoke this on video completion but doesn't help. AppDelegate returns value first then this event is invoked.
Task.Delay(7000).Wait(); // video is 7 seconds long
}
catch (Exception ex)
{
Console.WriteLine("======== "+ex.Message);
}
Window.RootViewController = null;
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return true;
}
//private bool Control_VideoCompletionEvent()
//{
// //Window.RootViewController = null;
// //global::Xamarin.Forms.Forms.Init();
// //LoadApplication(new App());
// //return true;
//}
}
VideoViewController
和VideoCutter
文件与上面链接中的相同。
谢谢