Thursday, April 12, 2012

MPMoviePlayerController not working in iOS 5 xcode (with storyboard), but works perfectly in iOS 4

I'm having problems playing a movie with the new xcode that comes with iOS 5 beta. I created a simple project (with storyboards and all), and added this code to a button:



MPMoviePlayerController *moviePlayer;
NSString *path = [[NSBundle mainBundle] pathForResource:@"position" ofType:@"m4v"];
NSURL *videoURL = [NSURL fileURLWithPath:path];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
//[moviePlayer setControlStyle:MPMovieControlStyleDefault];
[moviePlayer.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer play];


The confusing thing is that it works perfectly when I throw the code into a project built with a previous version of xcode (specifically the one that comes with iOS 4.3).



Any ideas?





No comments:

Post a Comment