AVQueuePlayer playback without gap and freeze

后端 未结 3 1934
无人及你
无人及你 2020-12-05 12:19

I use AVQueuePlayer to play a sequence of movies which are loaded from URLs.
I tried to initialize player instance with array of all AVPlayerItems

3条回答
  •  心在旅途
    2020-12-05 12:33

    Here is solution.

    - (void)_makePlayer{
         _player = [[AVQueuePlayer alloc] initWithPlayerItem:[AVPlayerItem playerItemWithAsset:[SSMoviePreviewItemMaker generateAVMovieItem]]];
    }
    
    + (AVAsset *)generateAVMovieItem{
        NSArray * array = [SSMovieFileManager getAllMovieResourceURL];
        AVMutableComposition *composition = [[AVMutableComposition alloc] init];
        for (int i = 0; i < array.count; i++) {
            AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:array[i] options:nil];
            [composition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration)
                                 ofAsset:asset
                                  atTime:composition.duration error:nil];
    
        }
       return composition;
    }
    

提交回复
热议问题