我有一个MPMoviePlayerViewController来全屏播放电影。我通过Quicktime检查了他们播放的电影。 问题是,使用MPMoviePlayerViewController(模拟器和设备)电影无法开始播放(这是一个本地存储在iPad上的视频)。
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];
任何想法我错过了什么?
TIA
答案 0 :(得分: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];