As the title says my MPMoviePlayerController should display on the button press but instead only the audio plays. I know it's not a problem with my video file as I have tried several including a sample video of the .mp4 format from apple.
Here is my code:
Code:
-(IBAction)playVideo:(id)sender {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"movie" ofType:@"mp4"];
NSURL *movieURL;
if (moviePath)
{
movieURL = [NSURL fileURLWithPath:moviePath];
}
if (movieURL != nil) {
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.fullscreen = YES;
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[moviePlayer play];
}
}
-(void)moviePlayBackDidFinish: (NSNotification*)notification
{
moviePlayer = [notification object];
[moviePlayer stop];
}
Can you see any issues? I'm using iOS4.0 and SDK 4.0.
Thanks