MPMoviePlayerController in iOS4 horizontal

I updated XCode and my iPhone SDK today to the latest 3.2.3 and iPhone OS4 only to find that it broke my video players, so below is the code to play it the same way in the iPhone OS4 SDK. (name is the variable for the file reference string)

[code lang="c"]
NSString *urlStr = [[NSBundle mainBundle] pathForResource:name ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.view.frame = [[UIScreen mainScreen] applicationFrame];
moviePlayer.view.transform = CGAffineTransformMakeRotation(1.57079633);
moviePlayer.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
[self.view addSubview:moviePlayer.view];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieScalingModeDidChange:)
name:MPMoviePlayerScalingModeDidChangeNotification
object:moviePlayer];
[moviePlayer play];
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *