MPMoviePlayerController视频播放

需要包含头文件 #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]];
// 网络视频使用
// NSURL*videoPath = [NSURL URLWithString:@"http://www.xxx.com/1.mp4"]
self.player.view.frame = self.view.frame;
[self.view addSubview:self.player.view];
// 不需要进度条
self.player.controlStyle = MPMovieControlStyleNone;
// 是否自动播放(默认为YES)
self.player.shouldAutoplay = YES;
// 播放本地视频时需要
self.player.movieSourceType = MPMovieSourceTypeFile;
// 开始播放
[self.player play];

推荐阅读更多精彩内容