Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jawngee/659109 to your computer and use it in GitHub Desktop.
Save jawngee/659109 to your computer and use it in GitHub Desktop.
-(void)setMovie:(QTMovie *)smovie
{
if (frameCache!=nil)
[frameCache release];
frameCache=[[NSMutableArray array] retain];
QTTimeRange range=QTMakeTimeRange(QTMakeTime(0,600), [smovie duration]);
QTMovie *copiedMovie=[[QTMovie alloc] initWithMovie:smovie timeRange:range error:nil];
ILFrameGrabber *grabber=[[ILFrameGrabber alloc] initWithMovie:copiedMovie];
ratio=grabber.width/grabber.height;
NSRect screen=[[NSScreen mainScreen] frame];
NSInteger frameCount=screen.size.width/[self bounds].size.height;
NSInteger delta=grabber.frameCount/frameCount;
dispatch_queue_t frameQueue = dispatch_queue_create( "com.interfacelab.shave.frame", NULL );
for (int i=0; i<frameCount; i++)
dispatch_async(frameQueue,^{
[frameCache addObject:[grabber nsImageAtFrame:i*delta]];
dispatch_async(dispatch_get_main_queue(), ^{
[self setNeedsDisplay:YES];
NSLog(@"loaded frame %d",i*delta);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment