zoukankan      html  css  js  c++  java
  • iOS开发--利用MPMoviePlayerViewController播放视频简单实现

    一.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
  • 相关阅读:
    sql优化
    什么是泛型
    Http Status 400
    Hadoop搭建伪分布式 & 上传和下载文件
    Centos64 安装指南
    个人感悟
    zabbix4.0部署
    MySQL引擎
    mysql正则表达式
    k8s自动补全命令
  • 原文地址:https://www.cnblogs.com/gchlcc/p/5583576.html
Copyright © 2011-2022 走看看