I have been trying to set the frame of the MPMoviePlayerController. But the app is crashing at the line player.view.frame = CGRectMake (0,0,480,320);
in iOS 3.1.3 but works fine on iOS 3.2 or greater. What might be the problem?
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"aVideo.mp4" ofType:@""]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the new 3.2 style API
moviePlayer.repeatMode = YES;
moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
}
else {
Use the old 2.0 style API
moviePlayer.view.frame = CGRectMake (0,0,480,320);
[self.view addSubview: [moviePlayer view]];
moviePlayer.movieControlMode = MPMovieControlStyleDefault;
[moviePlayer play];
}
}