我正在尝试使用Xcode的一些示例代码在iPhone模拟器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];
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
PS:我在Xcode 4.3.2上