Skip to content

Instantly share code, notes, and snippets.

@anthonyherron
Created October 25, 2011 14:09
Show Gist options
  • Save anthonyherron/1312852 to your computer and use it in GitHub Desktop.
Save anthonyherron/1312852 to your computer and use it in GitHub Desktop.
Gist for Faizan
-(void)setupPlayer
{
// adds the player to the view, player is an instance of MPMoviePlayerController
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/11ajdjnvkjnd10weoihf23ohfoihqw/sl_mvp.m3u8"]];
// loads the movie with the above URL
player.view.frame = self.bounds;
player.view.userInteractionEnabled = YES;
[self addSubview:self.player.view];
[self.player prepareToPlay];
// opts in to receive a callback every time metadata is provided through the stream
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(metaDataReceived:)
name:MPMoviePlayerTimedMetadataUpdatedNotification
object:nil];
// play
[self.player play];
}
-(void)metaDataReceived:(NSNotification *)notification
{
// handle the metadata callback here, so e.g. check the contents of a dictionary / display an image etc.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment