【发布时间】:2012-04-26 03:51:08
【问题描述】:
我正在尝试使用 Xcode 中的一些示例代码在 iPhone Simulator 5.1 下播放 mp4 视频。我创建了 MPMovieViewController 和 MPMovieController,提供了一个包含 mp4 的本地路径并将其作为子视图添加到我的根控制器。
当我在 iPhone 模拟器下运行它时,只显示后屏。我已经尝试了一些关于 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 xcode4.3