MPMoviePlayerViewController 未出现

发布于 2024-10-14 04:26:01 字数 1179 浏览 3 评论 0原文

我正在尝试为标题/启动屏幕加载一部小电影。但是,当我调用 presentMoviePlayerViewControllerAnimated 时,什么也没有发生。我已经确认该代码块正在执行,但用户无法感知到任何内容。

我的目标是 iPad,因此假设为 3.2。

任何帮助将不胜感激。

- (void)viewDidLoad {
  [super viewDidLoad];

  NSString *path = [[NSBundle mainBundle] pathForResource:@"Intro" ofType:@"m4v" inDirectory:nil];
  NSURL *fileURL = [NSURL fileURLWithPath:path];
  MPMoviePlayerViewController *playerView = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
  [[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(playbackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerView.moviePlayer];
  [self presentMoviePlayerViewControllerAnimated:playerView];
  [playerView release];
}

- (void)playbackDidFinish:(NSNotification*)aNotification {
  MPMoviePlayerController *player = [aNotification object];
  [[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:player];
  [player stop];
  [self dismissMoviePlayerViewControllerAnimated];
}

I'm attempting to load a small movie for a Title/Splash screen. However, when I call presentMoviePlayerViewControllerAnimated nothing happens. I have confirmed that the block of code is being executed, but there is nothing perceptible to the user.

I am targeting the iPad, so 3.2 is assumed.

Any help would be appreciated.

- (void)viewDidLoad {
  [super viewDidLoad];

  NSString *path = [[NSBundle mainBundle] pathForResource:@"Intro" ofType:@"m4v" inDirectory:nil];
  NSURL *fileURL = [NSURL fileURLWithPath:path];
  MPMoviePlayerViewController *playerView = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
  [[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(playbackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerView.moviePlayer];
  [self presentMoviePlayerViewControllerAnimated:playerView];
  [playerView release];
}

- (void)playbackDidFinish:(NSNotification*)aNotification {
  MPMoviePlayerController *player = [aNotification object];
  [[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:player];
  [player stop];
  [self dismissMoviePlayerViewControllerAnimated];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

私野 2024-10-21 04:26:01

你应该放置这条线
[玩家视图发布];

这条线
[自我解雇MoviePlayerViewControllerAnimated];

you should place the line
[playerView release];
after
this line
[self dismissMoviePlayerViewControllerAnimated];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文