gpt4 book ai didi

ios - 在应用启动时显示介绍视频

转载 作者:行者123 更新时间:2023-11-29 11:09:24 26 4
gpt4 key购买 nike

我必须在应用程序启动时显示一个小的介绍视频,我也必须显示初始屏幕 (DEFAULT.png)。所以在我的第一个 View Controller 的 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];

但是在这个实现中,当播放器 View 被添加到 View 时总是有一个黑色的闪光。有什么办法可以避免黑闪吗?

最佳答案

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

确保你没有动画。

关于ios - 在应用启动时显示介绍视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12209944/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com