Как лучше всего воспроизводить видео в UITableViewCell?

Я пытаюсь сделать автоматическое воспроизведение видео вUITableViewCell в зависимости от положения ячейки.

Я используюAVPlayer

Вот мой код:

    __weak typeof(self)this = self;

    NSString* videoPath = @"http://test.com/test.mp4";
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL URLWithString:videoPath] options:nil];
    NSArray* keys = [NSArray arrayWithObjects:@"playable",nil];

    [asset loadValuesAsynchronouslyForKeys:keys completionHandler:^(){
        AVPlayerItem* playerItem = [AVPlayerItem playerItemWithAsset:asset];
        this.avPlayer = [AVPlayer playerWithPlayerItem:playerItem];
        this.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:this.avPlayer];
        this.avPlayerLayer.frame = _videoContent.frame;

        dispatch_async(dispatch_get_main_queue(),^{
            [this.videoContent.layer addSublayer:this.avPlayerLayer];
            [this.avPlayer play];
        });
    }];

Но мой UITableView заморожен, когда я прокручиваю таблицу. Я думаю, что есть много трудоемкой работы, но самое главное

[this.avPlayer play]

Так что мой вопрос в том, что AVPlayer - лучший способ в этой ситуации? И есть ли способ улучшить производительность?

Ответы на вопрос(2)

Ваш ответ на вопрос