我正在尝试使用 Xcode 中的一些示例代码在 iPhone Simulator 5.1 下播放 mp4 视频。我创建了 MPMovieViewController 和 MPMovieController,提供包含 mp4 的本地路径并将其作为 subview 添加到我的根 Controller 。
当我在 iPhone Simulator 下运行它时,只显示后屏。我已经在 SO 中尝试了一些针对相同问题的建议,但仍然不起作用。
这是代码:
NSURL *myURL = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"VIDEO_CX75_01" ofType:@"mp4"]];
MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:myURL];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: myURL];
[self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];
[player.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: player.view];
player.view.frame = self.view.frame;
player.initialPlaybackTime = -1.0;
[player prepareToPlay];
[player play];
我在哪里做错了?
PS:我在 Xcode 4.3.2
最佳答案
我遇到了同样的问题,我所做的就是让玩家成为一个强大的属性并合成它。有效。
也应该适用于您的情况。!
关于ios5 - 初始化并播放 MPMoviePlayerController 返回黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10326980/