Created
October 25, 2011 14:09
-
-
Save anthonyherron/1312852 to your computer and use it in GitHub Desktop.
Gist for Faizan
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
-(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