First Add Framework for MPMoviePlayerController : “MediaPlayer.Framework”
.h File
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@class MPMoviePlayerController;
@interface TestViewController : UIViewController
{
MPMoviePlayerController *moviePlayer;
}
—————————————————————————-
.m File
-(void)ViewDidLoad
{
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@”Movie-1″ ofType:@”mp4″]]];
moviePlayer.view.frame = CGRectMake(0, 0, 320, 480);
[moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[moviePlayer setFullscreen:YES animated:YES];
moviePlayer.shouldAutoplay = YES;
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer play];
[self.view addSubview:moviePlayer.view];
}
-(void) moviePlayBackDidFinish:(NSNotification*)notification
{
[self dismissModalViewControllerAnimated:NO];
}