IOS: multimedia (18-01-25), ios multimedia 18-01-25
1. Audio
2. Video
1,
2. AVPlayer
1. Audio
2. Video
1,
2. AVPlayer
0) write in front
AVPlayer mainly includes AVPlayer, AVPlayerItem, and AVPlayerLayer, which correspond to Controller C, Model M, and view V respectively.
1) AVPlayer (Controller C)
2) AVPlayerItem (Model M)
2-1). Video duration:
AVPlayerItem. duration is CMTime type
Typedef struct {CMTimeValue value; // Number of frames CMTimeScale timescale; // Frame Rate (several frames per second) CMTimeFlags flags; CMTimeEpoch epoch;} CMTime;
The total number of seconds of the Video = duration. value/duration. timeScale.
OR = CMTimeGetSeconds (AVPlayerItem. duration ).
2-2) jump to a certain time point
CMTime time1 = CMTimeMake (120, 60); CMTime time2 = CMTimeWithSeconds (2.0, 1); [self. avItem seekToTime: time1 completionHandler: ^ (BOOL finished) {// after the jump is complete}];
Both CMTimeMake and CMTimeWithSeconds jump to the first parameter/second parameter = 2 seconds.
I personally think the difference between the two is to give developers a reference object, for example:
The first function, CMTimeMake, knows the number of frames per second and jumps to the specified number of frames.
The second function, CMTimeWithSeconds, knows the number of seconds to jump to and then sets the second parameter.
3) AVPlayerLayer (view V)