首页 > 移动平台 > 详细

iOS开发--利用MPMoviePlayerViewController播放视频简单实现

时间:2016-06-14 14:01:48      阅读:262      评论:0      收藏:0      [点我收藏+]

一.MPMoviePlayerViewController和MPMoviePlayerController区分开,前者继承自NSObject,后者继承自UIViewController

二.MPMoviePlayerViewController只能用modal出来的形式播放,并且一定是全屏的播放

 1 #import "ViewController.h"
 2 #import <MediaPlayer/MediaPlayer.h>
 3 
 4 @interface ViewController ()
 5 
 6 /* 创建播放控制器 */
 7 @property (nonatomic, strong) MPMoviePlayerViewController *playerVc;
 8 - (IBAction)play;
 9 
10 @end
11 
12 @implementation ViewController
13 
14 - (void)viewDidLoad {
15     [super viewDidLoad];
16 }
17 
18 #pragma mark - 懒加载代码
19 - (MPMoviePlayerViewController *)playerVc
20 {
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

 

iOS开发--利用MPMoviePlayerViewController播放视频简单实现

原文:http://www.cnblogs.com/gchlcc/p/5583576.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!