2

I have a MPMoviePlayerViewController to play Movies in fullscreen. I checked the movies they play fine via Quicktime. The Problem is, that using the MPMoviePlayerViewController (Simulator and device) the Movie doesn't start playing(it's a video that is stored locally on the iPad btw).

NSString *path = [[NSBundle mainBundle]pathForResource:resource ofType:@"mov"];
self.mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:path]];
[self.mpviewController.moviePlayer prepareToPlay];
self.mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
self.mpviewController.moviePlayer.controlStyle = [self presentModalViewController:self.mpviewController animated:YES];

NSLog(@"%d",self.mpviewController.moviePlayer.loadState);

[self.mpviewController.moviePlayer play];

Any Ideas what I am missing ?

tia

4

1 回答 1

0

好吧,我不知道那是什么。我最终用这段代码编写了一个新的视图控制器——它有效:

NSURL *url = [NSURL fileURLWithPath:self.urlPath];

self.playerController = [[MPMoviePlayerController alloc] initWithContentURL: url];
CGRect bounds = CGRectMake(0, 0, 1024, 748);
self.playerController.scalingMode = MPMovieScalingModeNone;

[self.playerController.view setFrame:bounds];

[self.view addSubview:self.playerController.view];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayerDidExitFullscreenCallback:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:self.playerController];

self.playerController.controlStyle = MPMovieControlStyleFullscreen;
[self.playerController setFullscreen:YES animated:YES];
[self.playerController play];
于 2012-09-28T07:35:10.593 回答