我的Resources文件夹中有一个名为lebron.mp4的mp4文件:
-(IBAction)videoButtonClicked:(id)sender{
NSString *url = [[NSBundle mainBundle]
pathForResource:@"lebron"
ofType:@"mp4"];
MPMoviePlayerViewController* moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];
moviePlayerViewController.view.backgroundColor = [UIColor blackColor];
[self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];
[moviePlayerViewController release];
}
显示电影播放器,但电影无法播放。为什么呢?
答案 0 :(得分:0)
你试图像这样显示它:
[moviePlayerViewController play];
[window addSubview: MPMoviePlayerViewController.view];