Skip to content

Instantly share code, notes, and snippets.

@osmszk
Created April 5, 2015 01:49
Show Gist options
  • Save osmszk/4e155b867a9199c806d2 to your computer and use it in GitHub Desktop.
Save osmszk/4e155b867a9199c806d2 to your computer and use it in GitHub Desktop.
Play Movie
@property (strong,nonatomic) MPMoviePlayerController *player;
- (void)viewDidLoad
{
NSURL *url = [NSURL URLWithString:@"http://www.gomplayer.jp/img/sample/mp4_h264_aac.mp4"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
player.controlStyle = MPMovieControlStyleNone;
self.player = player;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:player];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
player.view.frame = CGRectMake(0, 0, 320, 200);
[self.view addSubview:player.view];
[player prepareToPlay];
}
- (void)moviePreloadDidFinish:(id)sender
{
}
- (void)moviePlayerPlaybackDidFinish:(id)sender
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment