一.MPMoviePlayerViewController和MPMoviePlayerController区分开,前者继承自NSObject,后者继承自UIViewController
二.MPMoviePlayerViewController只能用modal出来的形式播放,并且一定是全屏的播放
1 #import "ViewController.h" 2 #import3 4 @interface ViewController () 5 6 /* 创建播放控制器 */ 7 @property (nonatomic, strong) MPMoviePlayerViewController *playerVc; 8 - (IBAction)play; 9 10 @end11 12 @implementation ViewController13 14 - (void)viewDidLoad {15 [super viewDidLoad];16 }17 18 #pragma mark - 懒加载代码19 - (MPMoviePlayerViewController *)playerVc20 {21 if (_playerVc == nil) {22 NSURL *url = [NSURL URLWithString:@"http://v1.mukewang.com/19954d8f-e2c2-4c0a-b8c1-a4c826b5ca8b/L.mp4"];23 24 _playerVc = [[MPMoviePlayerViewController alloc] initWithContentURL:url];25 }26 return _playerVc;27 }28 29 - (IBAction)play {30 [self presentViewController:self.playerVc animated:YES completion:nil];31 }32 33 @end