Last active
August 29, 2015 14:05
-
-
Save Bayonetta/3433a9cdb4ee4440a07a to your computer and use it in GitHub Desktop.
handle video completed
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)startPlaybackForItemWithURL:(NSURL*)url { | |
// First create an AVPlayerItem | |
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:url]; | |
// Subscribe to the AVPlayerItem's DidPlayToEndTime notification. | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:playerItem]; | |
// Pass the AVPlayerItem to a new player | |
AVPlayer* player = [[[AVPlayer alloc] initWithPlayerItem:playerItem] autorelease]; | |
// Begin playback | |
[player play] | |
} | |
-(void)itemDidFinishPlaying:(NSNotification *) notification { | |
// Will be called when AVPlayer finishes playing playerItem | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment