Skip to content

Instantly share code, notes, and snippets.

@bcjwilson
Created July 17, 2012 22:01
Show Gist options
  • Save bcjwilson/3132449 to your computer and use it in GitHub Desktop.
Save bcjwilson/3132449 to your computer and use it in GitHub Desktop.
- (void)setupSetVideoListener
{
[emitter on:BCEventSetVideo doChain:^(BCEvent *setVideoEvent, BCEventEmitterChain *chain){
BCVideo *video = [setVideoEvent.details objectForKey:@"video"];
[chain on:BCEventSetVideo callBlock:^(BCEvent *innerSetVideoEvent){
[chain abort];
}];
[chain emit:BCEventShouldSetVideo];
[chain thenDo:^(BCEvent *shouldSetVideoEvent){
if (shouldSetVideoEvent.defaultPrevented) {
[chain emit:BCEventCancelledSetVideo parentEvent:setVideoEvent];
[chain abort];
}
}];
[chain emit:BCEventWillSetVideo parentEvent:setVideoEvent];
[chain emit:BCEventSetRendition withDetails:
[NSDictionary dictionaryWithObject:rendition forKey:@"rendition"]];
[chain emit:BCEventSetVideoStill withDetails:
[NSDictionary dictionaryWithObject:videoStill forKey:@"videoStill"]];
[chain waitForBoth:BCEventDidSetRendition and:BCEventDidSetVideoStill];
[chain thenDo:^{
self.video = video;
[chain emit:BCEventDidSetVideo parentEvent:setVideoEvent];
}];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment