PDA

View Full Version : Video not playing in iOS4




jackdvdripper
Jul 16, 2010, 09:03 PM
I have the following code to play a video when a button is pushed in my app
- (IBAction)play {

NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"mom" ofType:@"mp4"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];

}

It played just fine until I upgraded my iPhone to iOS4. Now the audio will play, but not the video. Is there a reason for this?



CeiJay
Jul 17, 2010, 06:30 PM
Since 3.2 and really iOS4 there have been a few changes when is comes to playing movie. MPMoviePlayerController is sort of out now. MoviePlayerViewController is in (notice the View) have a look at the like below, download the source code and you will have it working in no time. Make sure you test on run for leaks on your device as you will see a few things wrong with the Sim. All the best...

Click Me for the Solution (http://iphonedevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html)