需要包含頭文件 #import <MediaPlayer/MediaPlayer.h>和MediaPlayer.framework
#import <MediaPlayer/MediaPlayer.h>
@property (nonatomic,strong) MPMoviePlayerController *player;
// 本地視頻
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"];
self.player = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath:videoPath]];
// 網(wǎng)絡(luò)視頻使用
// NSURL*videoPath = [NSURL URLWithString:@"http://www.xxx.com/1.mp4"]
self.player.view.frame = self.view.frame;
[self.view addSubview:self.player.view];
// 不需要進(jìn)度條
self.player.controlStyle = MPMovieControlStyleNone;
// 是否自動(dòng)播放(默認(rèn)為YES)
self.player.shouldAutoplay = YES;
// 播放本地視頻時(shí)需要
self.player.movieSourceType = MPMovieSourceTypeFile;
// 開(kāi)始播放
[self.player play];