Good resources

http://mobile.tutsplus.com/tutorials/iphone/mediaplayer-framework_mpmovieplayercontroller_ios4/

Playing A Movie File

Add MediaPlayer.framework in the Frameworks folder

Select-> Frameworks folder -> Add ->Existing Frameworks -> then select MediaPlayer.framework.

In your .h file

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>

//In @interface:
MPMoviePlayerController *moviePlayerController;
In your .m file

//***************************************
//***************************************
//********** PLAY MEDIA BUTTON **********
//***************************************
//***************************************
- (IBAction)PlayMediaButton:(id)sender
{

	NSString *path;
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"MyVideos"];
	path = [path stringByAppendingPathComponent:@"MyMovieFile.MOV";

	if ([[NSFileManager defaultManager] fileExistsAtPath:path])		//Does file exist?
	{
		moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];

		[[NSNotificationCenter defaultCenter] addObserver:self
												 selector:@selector(moviePlaybackComplete:)
													 name:MPMoviePlayerPlaybackDidFinishNotification
												   object:moviePlayerController];  

		[self.view addSubview:moviePlayerController.view];
		moviePlayerController.fullscreen = YES;

		if ([moviePlayerController respondsToSelector:@selector(setAllowsAirPlay:)])	//Allow airplay if availabe
			[moviePlayerController setAllowsAirPlay:YES];

		[moviePlayerController play];
	}
}

//*******************************************
//*******************************************
//********** MOVIE PLAYER COMPLETE **********
//*******************************************
//*******************************************
//(You can't release the MoviePlayer after triggering play even using autorelease - you need to do it once you have ensured playback is complete)
- (void)moviePlaybackComplete:(NSNotification *)notification
{
	//MPMoviePlayerController *moviePlayerController = [notification object];
	[[NSNotificationCenter defaultCenter] removeObserver:self
													name:MPMoviePlayerPlaybackDidFinishNotification
												  object:moviePlayerController];  

	[moviePlayerController.view removeFromSuperview];
	[moviePlayerController release];
}

Playing In An Area Of The Screen


	moviePlayerController.view.frame = CGRectMake(10, 10, 300, 300);
	[self.view addSubview:moviePlayerController.view];

MPMoviePlayerController Stopped Working in iOS5?

We came across an issue which appeared with iOS 5 playback of movie files to which the path had been stored as a string. In iOS 4 this worked fine:

moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:path]];

But not in iOS 5! Instead the movie window opened and immediately closed again. This was the solution:

moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];