iOS:多媒体(18-01-25更)

1、音频

2、视频

  1、

  2、AVPlayer

 

1、音频

 

 

 

 

2、视频

  1、

 

 

  2、AVPlayer

    0)、写在前面

      AVPlayer 主要包含 AVPlayer、AVPlayerItem、AVPlayerLayer,分别对应,控制器C、模型M、视图V。

    1)、AVPlayer(控制器C)

 

    2)、AVPlayerItem(模型M)

      2-1)、影片时长:

        AVPlayerItem.duration 是 CMTime 类型

typedef struct{
    CMTimeValue    value;          // 帧数
    CMTimeScale    timescale;    // 帧率(影片每秒有几帧)
    CMTimeFlags    flags;        
    CMTimeEpoch    epoch;
} CMTime;

        影片的总秒数 = duration.value / duration.timeScale 。

             或 = CMTimeGetSeconds( AVPlayerItem.duration )。

      2-2)、跳到某个时刻  

CMTime time1 = CMTimeMake(120, 60);
CMTime time2 = CMTimeWithSeconds(2.0, 1);

[self.avItem seekToTime:time1 completionHandler:^(BOOL finished) {
    // 跳转完成后
}];

        CMTimeMake、CMTimeWithSeconds,都是跳到 第一个参数/第二个参数 = 2秒。

        两者的区别,我个人认为是为了让开发者有个参照物,比如:

          第一个函数 CMTimeMake,知道每秒几帧,跳到指定的帧数。

          第二个函数 CMTimeWithSeconds ,知道要跳到第几秒,从而设置第二个参数。

          

          

 

 

    3)、 AVPlayerLayer(视图V)

 

posted on 2018-01-25 17:27  leonlincq  阅读(270)  评论(0编辑  收藏  举报