【问题标题】:Showing Intro Video at app launch在应用启动时显示介绍视频
【发布时间】:2012-08-31 06:26:13
【问题描述】:

我必须在应用启动时显示一个小的介绍视频,并且我还必须显示启动画面 (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];

但是在这个实现中,当将播放器视图添加到视图时,总是会出现黑色闪烁。有什么办法可以避免黑闪?

【问题讨论】:

    标签: ios mpmovieplayercontroller


    【解决方案1】:

    与其在你的 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];
    

    确保以无动画的形式呈现它。

    【讨论】:

    • Manish 感谢您的关注,但无济于事。
    【解决方案2】:

    我认为没有办法避免这种情况,因为当应用程序尝试执行此行时屏幕会闪烁:

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

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

    所以我认为执行此操作时您无能为力。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-05
      • 2015-02-04
      相关资源
      最近更新 更多