Skip to content

Instantly share code, notes, and snippets.

@MrBendel
Last active March 15, 2016 23:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MrBendel/a9140d0318e2aec64727 to your computer and use it in GitHub Desktop.
Save MrBendel/a9140d0318e2aec64727 to your computer and use it in GitHub Desktop.
// the cell creation logic
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UVLVideoCell *videoCell = (UVLVideoCell *)[collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([UVLVideoCell class]) forIndexPath:indexPath];
NSInteger index = 1 + indexPath.item%2;
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:[NSString stringWithFormat:@"flak_0%i", index] withExtension:@"mp4" subdirectory:@"videos"];
[videoCell loadVideoURL:sampleURL];
return videoCell;
}
// inside the cell
- (void)loadVideoURL:(NSURL *)url
{
self.gpuMovie = [[GPUImageMovie alloc] initWithURL:url];
self.gpuMovie.shouldRepeat = YES;
[self.gpuMovie addTarget:self.gpuView];
[self.gpuMovie startProcessing];
}
// called when cell goes off-screen
- (void)didEndDisplayingCell
{
[self.gpuMovie cancelProcessing];
self.gpuMovie = nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment