Last active
March 15, 2016 23:17
-
-
Save MrBendel/a9140d0318e2aec64727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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