The MPMoviePlayerController plays video content. You initialize it with the URL of the media play which can be either a path to a local movie file or the URL of network based media.  The movie player view is added as a subview of a view with the playback window run in full screen mode or embedded in a view.

Playing A Movie

Add The MediaPlayer Framework To You Project

Select the project at the top of the left navigator panel, then select the Build Phases tab. In the Link Binary with Libraries section click the ‘+’ button and then select the MediaPlayer.framework entry.

In your #ViewController.h file

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
In your #ViewController.m file

	//----- PLAY THE MOVIE -----
	NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MOVIE" ofType:@"MOV"]];

	MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

	[[NSNotificationCenter defaultCenter] addObserver:self
											 selector:@selector(moviePlayBackDidFinish:)
												 name:MPMoviePlayerPlaybackDidFinishNotification
											   object:moviePlayer];

	moviePlayer.controlStyle = MPMovieControlStyleDefault;
	moviePlayer.shouldAutoplay = YES;
	[self.view addSubview:moviePlayer.view];
	[moviePlayer setFullscreen:YES animated:YES];

//***********************************************
//***********************************************
//********** MOVIE PLAYBACK DID FINISH **********
//***********************************************
//***********************************************
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{

    MPMoviePlayerController *moviePlayer = [notification object];

    [[NSNotificationCenter defaultCenter] removeObserver:self      
													name:MPMoviePlayerPlaybackDidFinishNotification
												  object:moviePlayer];

	NSLog(@"Movie playback finished");

	if ([moviePlayer 
		 respondsToSelector:@selector(setFullscreen:animated:)])
	{
		[moviePlayer.view removeFromSuperview];
	}
	[moviePlayer release];
}

Good Resources

http://www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_4_iPhone_Application

User Controls

The movie player includes controls by default for the user to manage playback. This may be configured using the controlStyle property.

UPDATED CODE

A user was kind enough to tell us that this code is out of date now as it is for iOS4. Its a while since we’ve needed to implement movieplayer in an app but here is the code they gave us which apparently works well

UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface Playing_Video_FilesViewController : UIViewController
@property (nonatomic, strong) MPMoviePlayerController *moviePlayer;
@property (nonatomic, strong) UIButton *playButton;
@end
 - (void) startPlayingVideo:(id)paramSender{
  NSBundle *mainBundle = [NSBundle mainBundle];
  NSString *urlAsString = [mainBundle pathForResource:@"Sample"
                                               ofType:@"m4v"];
  NSURL    *url = [NSURL fileURLWithPath:urlAsString];
  if (self.moviePlayer != nil){
    [self stopPlayingVideo:nil];
}
 
  self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
  if (self.moviePlayer != nil){
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(videoHasFinishedPlaying:)
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:self.moviePlayer];
    NSLog(@"Successfully instantiated the movie player.");
    
    self.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

    [self.moviePlayer play];
    [self.view addSubview:self.moviePlayer.view];
    [self.moviePlayer setFullscreen:YES
                           animated:YES];
  } else {
    NSLog(@"Failed to instantiate the movie player.");
} 
}
- (void) stopPlayingVideo:(id)paramSender {
  if (self.moviePlayer != nil){
    [[NSNotificationCenter defaultCenter]
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:self.moviePlayer];
    [self.moviePlayer stop];
    if ([self.moviePlayer.view.superview isEqual:self.view]){
      [self.moviePlayer.view removeFromSuperview];
} }
}
- (void) viewDidUnload{
  self.playButton = nil;
  [self stopPlayingVideo:nil];
  self.moviePlayer = nil;
  [super viewDidUnload]; 
}
- (void) videoHasFinishedPlaying:(NSNotification *)paramNotification{
  /* Find out what the reason was for the player to stop */
  NSNumber *reason =
  [paramNotification.userInfo
   valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
  if (reason != nil){
    NSInteger reasonAsInteger = [reason integerValue];
    switch (reasonAsInteger){
      case MPMovieFinishReasonPlaybackEnded:{
        /* The movie ended normally */
break; }
      case MPMovieFinishReasonPlaybackError:{
        /* An error happened and the movie ended */
        break; 
}
case MPMovieFinishReasonUserExited:{
        /* The user exited the player */
        break;
} 
}
    NSLog(@"Finish Reason = %ld", (long)reasonAsInteger);
    [self stopPlayingVideo:nil];
  } /* if (reason != nil){ */ 
}