zoukankan      html  css  js  c++  java
  • 视频播放一

    1.使用注意事项

    导入框架
    #import <AVKit/AVKit.h>
    #import <AVFoundation/AVFoundation.h>
    

    2.使用

    AVPlayerViewController *_playerVc;
     Video *video = _videos[indexPath.row];
        NSString *url = [baseUrlStr stringByAppendingPathComponent:video.url];
      
        //ios9.0以下
        if([[UIDevice currentDevice].systemVersion doubleValue] >= 9.0){
            if (_playerVc == nil) {
                _playerVc = [[AVPlayerViewController alloc] init];
            }
            _playerVc.player = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:url]];
            /*
             可以设置的值及意义如下:
             AVLayerVideoGravityResizeAspect   不进行比例缩放 以宽高中长的一边充满为基准
             AVLayerVideoGravityResizeAspectFill 不进行比例缩放 以宽高中短的一边充满为基准
             AVLayerVideoGravityResize     进行缩放充满屏幕
             */
            _playerVc.videoGravity = AVLayerVideoGravityResizeAspectFill;
            [self presentViewController:_playerVc animated:YES completion:nil];
            [_playerVc shouldAutorotate];
        }else{
    //需要导入#import <MediaPlayer/MediaPlayer.h>框架
            MPMoviePlayerViewController *play = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];
            [self presentViewController:play animated:YES completion:nil];
        }
    

      

      

  • 相关阅读:
    【转】size_t和ssize_t
    WCF订票系统DEMO
    VS2008显示解决方案的方法
    一些好用的开源控件
    SQL 的Over 子句
    Sql2005高效分页语句
    使用winform的showdialog小心内存泄漏
    字符串连接类(Javascript)
    SharpZipLib 的使用
    浅谈持久化
  • 原文地址:https://www.cnblogs.com/TheYouth/p/6745252.html
Copyright © 2011-2022 走看看