iphoneiphone-sdk-3.2

Adding video to an iPhone application


How do I add a video to an iPhone app. using iPhone SDK 3.2.5? I dont see the actual video but I can hear it playing.

Here is the code:

-(void) viewDidLoad{
    NSBundle *bundle=[NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"Facebook" ofType:@"mp4"];
    NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    theMovie.scalingMode = MPMovieScalingModeAspectFill;
    [theMovie play];
    [super viewDidLoad];
}

Solution

  • You need to set the frame for you MPMoviePlayerController and add it to your view:

    theMovie.view.frame = CGRectMake(0.0, 0.0, 320.0, 480.0);
    [self.view addSubview:theMovie.view];