Show video in collection view cell
<p>I want to show multiple videos in a collection view. I have this code:</p>

<pre><code>-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return array.count;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];

    NSURL *videoURL = [NSURL fileURLWithPath:@"Path"];
    AVPlayer *player = [AVPlayer playerWithURL:videoURL];
    AVPlayerViewController *playerViewController = [AVPlayerViewController new];
    playerViewController.player = player;
    playerViewController.showsPlaybackControls = NO;
    playerViewController.videoGravity = AVLayerVideoGravityResizeAspectFill;

    playerViewController.view.frame = CGRectMake(0, 0, 200, 200);
    [cell insertSubview:playerViewController.view atIndex:0];

    [player play];

    return cell;

}
</code></pre>

<p>But the code is very slowly and the scrolling is not smooth. Can you help me? </p>