合并播放多段视频
self.composition = [[AVMutableComposition alloc] init];
AVMutableCompositionTrack *videoTrack = [self.composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
//可以加多个
AVAsset *asset = [AVAsset assetWithURL:@"视频地址"];
NSError *error = nil;
[videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration)
ofTrack:[[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
atTime:currentTime
error:&error];
假如:第一段105s;第二段80s ;第三段....
如果为多段,播放第一段时,点击播放下一段的时候,此时直接用下面代码,然后监控进度,会发现播放并不是从105开始,我这边是从100开始的
[self.movePlayer.player seekToTime:CMTimeMake(105, 1)];
可以改用如下方法就可以了
CMTime time = CMTimeMakeWithSeconds(105, self.player.currentItem.asset.duration.timescale);
[self.player seekToTime:time toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];