2012-08-31 51 views
1

我必须在应用程序启动时显示一个小的介绍视频,我也必须显示启动画面(DEFAULT.png)。 所以在我的第一个视图控制器的viewDidLoad中我做的:在应用程序启动时显示介绍视频

NSURL * movieUrl = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4"]]; 
    self.playerController = [[MPMoviePlayerViewController alloc]initWithContentURL:movieUrl]; 

    //Fit the screen 
    self.playerController.view.frame = CGRectMake(0, -20, 320, 480); 

    //Hide video controls 
    self.playerController.moviePlayer.controlStyle = MPMovieControlStyleNone; 

    //Play as soon as loaded 
    self.playerController.moviePlayer.shouldAutoplay = YES; 


    //Add the video as the first view background 
    [self.view addSubview:playerController.moviePlayer.view]; 

但是这个实现总是有当播放器视图添加到视图中的黑色闪光。有什么办法可以避免黑色闪光?

回答

2

比你firstViewController呈现的PlayerController相反,在处理的appDelegate这和现在过来窗口RootViewController的。

NSURL * movieUrl = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4"]]; 
self.playerController = [[MPMoviePlayerViewController alloc]initWithContentURL:movieUrl]; 

//Fit the screen 
self.playerController.view.frame = CGRectMake(0, -20, 320, 480); 

//Hide video controls 
self.playerController.moviePlayer.controlStyle = MPMovieControlStyleNone; 

//Play as soon as loaded 
self.playerController.moviePlayer.shouldAutoplay = YES; 

[self.window.rootViewController presentModalViewController:self.playerController animated:NO]; 

请确保您将它与无动画一起呈现。

+0

Manish感谢您的期待,但它没有帮助。 – Soni

0

我不认为有什么办法避免这一点,因为在屏幕上闪烁的黑色,当应用程序试图执行这一行:

[self.view addSubview:playerController.moviePlayer.view]; 

OR

[self.window.rootViewController presentModalViewController:self.playerController animated:NO]; 

所以我认为没有什么你可以在这个执行时做。

相关问题