在.h文件导入库文件
#import <MediaPlayer/MPMoviePlayerViewController.h>
在.m实现文件中
NSString *path=[[NSBundle mainBundle] pathForResource:@"name" ofType:@"mp4"];
NSURL *URL = [[NSURL alloc] initFileURLWithPath:path];
MPMoviePlayerViewController *_moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:URL];
[_moviePlayerController.moviePlayer play];
//自我控制
MPMoviePlayerController的位置--
MPMoviePlayerController *moviePlayer;
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"name"
ofType:@"mp4"];
if (moviePath) {
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:movieURL];
}
[[self view] addSubview:[moviePlayer view]];
[[moviePlayer view] setFrame:CGRectMake(0, 44, 320, 378)];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
[moviePlayer play];