I'm implementing a Media player in my iPad app, but the video won't play at all. It shows the video's first frame, but as soon as I press play, it pauses instantly after.
Any idea why this is happening? I think it probably has to do with the iPad being version 3.2.
Below is my code. Thanks in advance!
- (void)viewDidLoad {
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"Reel.m4v" ofType:nil];
NS开发者_如何学CURL *url = [NSURL fileURLWithPath:urlStr];
videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:videoPlayer.view];
videoPlayer.view.frame = CGRectMake(30, 180, 964, 493);
[videoPlayer stop];
[super viewDidLoad];
}
I figured it out through this post: Ipad MPMovieplayerController video loads but automatically pauses when played
I had to set this videoPlayer.useApplicationAudioSession = NO;
精彩评论