Skip to content

Instantly share code, notes, and snippets.

@ikekou
Created June 22, 2013 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikekou/5840178 to your computer and use it in GitHub Desktop.
Save ikekou/5840178 to your computer and use it in GitHub Desktop.
[Objective-C] URLを指定して動画を再生(MPMoviePlayerViewController使う場合)
/*--------------------------------------------------------------------------------
URLを指定して動画を再生
--------------------------------------------------------------------------------*/
- (void)playMovie:(NSURL *)url {
// MPMoviePlayerViewController作成
self.moviePlayerView = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
// 自動再生しない
MPMoviePlayerController *p=self.moviePlayerView.moviePlayer;
p.shouldAutoplay=NO;
// コントロールなし
p.controlStyle=MPMovieControlStyleNone;
// ループ
p.repeatMode=MPMovieRepeatModeOne;
// 再生してみる
[p play];
// モーダルとして表示させる
[self presentMoviePlayerViewControllerAnimated:self.moviePlayerView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment