问题
I have an mp4 file called lebron.mp4 in my Resources folder:
-(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];
}
Displays the movie player, but the movie doesn't play. Why?
回答1:
did you try to display it like this :
[moviePlayerViewController play];
[window addSubview: MPMoviePlayerViewController.view];
?
来源:https://stackoverflow.com/questions/4077096/how-can-i-play-a-movie-locally-with-the-mpmovieplayerviewcontroller