&bookmark_hatena()


MPMovieDurationAvailableNotification


Durationが決まったことを通知 。duration valueはduration property of the movie player controller。

MPMovieMediaTypesAvailableNotification


media typesが決まったことを通知。値はthe movieMediaTypes property of the movie player controller.

MPMovieNaturalSizeAvailableNotification


フレームサイズが決まったことを通知 The frame size value is reflected in the naturalSize property of the movie player controller.

MPMoviePlayerContentPreloadDidFinishNotification


Deprecated in iOS 3.2.

MPMoviePlayerDidEnterFullscreenNotification


フルスクリーンモードになったことを通知

MPMoviePlayerDidExitFullscreenNotification


フルスクリーンモードから抜けたことを通知

MPMoviePlayerLoadStateDidChangeNotification


LoadStateが変化したことを通知。LoadStateはloadStateプロパティに入っている。MPMoviePlayerController/LoadState

MPMoviePlayerNowPlayingMovieDidChangeNotification


現在再生中の映像が変化したことを通知。The currently playing movieはcontentURLプロパティから得られる。

MPMoviePlayerPlaybackDidFinishNotification


映像の再生の終了を通知。userInfoにはMPMoviePlayerPlaybackDidFinishReasonUserInfoKeyというキーが含まれていて、終了理由が書き込まれている。
このノティフィケーションはエラーによる再生の失敗時にも通知される。このノティフィケーションはフルスクリーンモードでユーザがDoneボタンを押したときは通知されない。
もし、Doneを感知したいときは、MPMoviePlayerDidExitFullscreenNotificationなどを使うこと。

enum {
  MPMovieFinishReasonPlaybackEnded,
  MPMovieFinishReasonPlaybackError,
  MPMovieFinishReasonUserExited
};

MPMoviePlayerPlaybackStateDidChangeNotification


再生状態が変化したことを通知する。変化した状態はplaybackStateプロパティで得られる。

   MPMusicPlaybackStateStopped 0
   MPMusicPlaybackStatePlaying 1
   MPMusicPlaybackStatePaused 2
   MPMusicPlaybackStateInterrupted 3
   MPMusicPlaybackStateSeekingForward 4 
   MPMusicPlaybackStateSeekingBackward 5



MPMoviePlayerScalingModeDidChangeNotification


スケーリングが変更されたことを通知する。

MPMoviePlayerThumbnailImageRequestDidFinishNotification


映画からサムネールをとるリクエストが完了していることを通知する。userInfoにはサムネールイメージについての複数のキーが含まれている。
userInfo はMPMoviePlayerThumbnailImageKey と MPMoviePlayerThumbnailTimeKey keysを含む。
エラーが起きている場合、MPMoviePlayerThumbnailErrorKey と MPMoviePlayerThumbnailTimeKeyを含む。

MPMoviePlayerWillEnterFullscreenNotification


フルスクリーンモードに入ったことを通知する。userInfoにはフルスクリーンモードに入るのに使われた遷移アニメーションを記述するキーが含まれている。

MPMoviePlayerWillExitFullscreenNotification


フルスクリーンモードから出たことを通知する。userInfoにはフルスクリーンモードから出たのに使われた遷移アニメーションを記述するキーが含まれている。

MPMovieSourceTypeAvailableNotification


映像のソースタイプが最初不明で後に判明したときに通知される。ソースタイプはthe movieSourceType propertyから得られる。

playbackstate

   MPMoviePlaybackStateStopped 0,
   MPMoviePlaybackStatePlaying 1,
   MPMoviePlaybackStatePaused 2,
   MPMoviePlaybackStateInterrupted 3,
   MPMoviePlaybackStateSeekingForward 4,
   MPMoviePlaybackStateSeekingBackward 5

MPMediaPlaybackIsPreparedToPlayDidChangeNotification

MPMediaPlayback Protocol

MPMoviePlayer 注意点

iOS6iPadでfullScreenに入った際に固まるバグが出ている。
http://openradar.appspot.com/12327997
MPMoviePlayerController behavior changed when entering full screen playback.




サンプル

- (void)setMPMovieNotify {
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
   
//[center addObserver:self selector:@selector(MPMoviePlayerLoadStateDidChangeNotification:) name:MPMoviePlayerLoadStateDidChangeNotification object:self.moviePlayer];
//[center addObserver:self selector:@selector(MPMediaPlaybackIsPreparedToPlayDidChangeNotification:) name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification object:self.moviePlayer];
   
[center addObserver:self selector:@selector(MPMovieDurationAvailableNotification) name:MPMovieDurationAvailableNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMovieMediaTypesAvailableNotification) name:MPMovieMediaTypesAvailableNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMovieNaturalSizeAvailableNotification) name:MPMovieNaturalSizeAvailableNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerDidEnterFullscreenNotification) name:MPMoviePlayerDidEnterFullscreenNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerDidExitFullscreenNotification) name:MPMoviePlayerDidExitFullscreenNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerNowPlayingMovieDidChangeNotification) name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerPlaybackDidFinishNotification) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerPlaybackStateDidChangeNotification) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerScalingModeDidChangeNotification) name:MPMoviePlayerScalingModeDidChangeNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerThumbnailImageRequestDidFinishNotification) name:MPMoviePlayerThumbnailImageRequestDidFinishNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerWillEnterFullscreenNotification) name:MPMoviePlayerWillEnterFullscreenNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMoviePlayerWillExitFullscreenNotification) name:MPMoviePlayerWillExitFullscreenNotification object:self.moviePlayer];
[center addObserver:self selector:@selector(MPMovieSourceTypeAvailableNotification) name:MPMovieSourceTypeAvailableNotification object:self.moviePlayer];
   
}

	-(void)removeMPMovieNotify{
   NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
//[center removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:self.moviePlayer];
//[center removeObserver:self name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification object:self.moviePlayer];
   [center removeObserver:self name:MPMovieDurationAvailableNotification object:self.moviePlayer];
[center removeObserver:self name:MPMovieMediaTypesAvailableNotification object:self.moviePlayer];
[center removeObserver:self name:MPMovieNaturalSizeAvailableNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerContentPreloadDidFinishNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerDidEnterFullscreenNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerScalingModeDidChangeNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerThumbnailImageRequestDidFinishNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerWillEnterFullscreenNotification object:self.moviePlayer];
[center removeObserver:self name:MPMoviePlayerWillExitFullscreenNotification object:self.moviePlayer];
[center removeObserver:self name:MPMovieSourceTypeAvailableNotification object:self.moviePlayer];
}

 -(void)MPMoviePlayerLoadStateDidChangeNotification{
   NSLog(@"MPMoviePlayerLoadStateDidChangeNotification %d",self.moviePlayer.loadState);
 }

 -(void)MPMediaPlaybackIsPreparedToPlayDidChangeNotification{
   NSLog(@"MPMediaPlaybackIsPreparedToPlayDidChangeNotification");
 }
 /*
 -(void)MPMovieDurationAvailableNotification{
   NSLog(@"MPMovieDurationAvailableNotification");
 }

 -(void)MPMovieMediaTypesAvailableNotification{
   NSLog(@"MPMovieMediaTypesAvailableNotification");
 }
 */
 -(void)MPMovieNaturalSizeAvailableNotification{
   NSLog(@"MPMovieNaturalSizeAvailableNotification");
 }

 -(void)MPMoviePlayerDidEnterFullscreenNotification{
   NSLog(@"MPMoviePlayerDidEnterFullscreenNotification");
 }

 -(void)MPMoviePlayerDidExitFullscreenNotification{
   NSLog(@"MPMoviePlayerDidExitFullscreenNotification");
 }

 -(void)MPMoviePlayerNowPlayingMovieDidChangeNotification{
   NSLog(@"MPMoviePlayerNowPlayingMovieDidChangeNotification");
 }

 -(void)MPMoviePlayerPlaybackDidFinishNotification{
   NSLog(@"MPMoviePlayerPlaybackDidFinishNotification");
 }

 -(void)MPMoviePlayerPlaybackStateDidChangeNotification{
   NSLog(@"MPMoviePlayerPlaybackStateDidChangeNotification %d",self.moviePlayer.playbackState);
 }

 -(void)MPMoviePlayerScalingModeDidChangeNotification{
   NSLog(@"MPMoviePlayerScalingModeDidChangeNotification");
 }

 -(void)MPMoviePlayerThumbnailImageRequestDidFinishNotification{
   NSLog(@"MPMoviePlayerThumbnailImageRequestDidFinishNotification");
 }

 -(void)MPMoviePlayerWillEnterFullscreenNotification{
   NSLog(@"MPMoviePlayerWillEnterFullscreenNotification");
 }

 -(void)MPMoviePlayerWillExitFullscreenNotification{
   NSLog(@"MPMoviePlayerWillExitFullscreenNotification");
 }

 -(void)MPMovieSourceTypeAvailableNotification{
   NSLog(@"MPMovieSourceTypeAvailableNotification");
 }

リファレンスの冒頭の概要

MoviePlayer(MPMoviePlayerControllerの類いの)は動画の再生をコントロールします。
動画はネットワークもしくはファイルから再生できます。
再生は、あるビューから行われます。
そのビューとはMoviePlayerが持っているビューです。
そして、そのビューはフルスクリーンでもインラインでもどちらでも再生することができます。
MoviePlayerのビューをアプリのビュー階層にいれこんで使う事もできますし、MPMoviePlayerViewControllerを使って制御する事もできます。

iOS4.3以降のMoviePlayerはAppleTVのようなエアプレイ可能なハードウェアへのワイアレスモービー再生をサポートしています。MoviePlayerはユーザーにそのようなハードウェアで再生可能なときに再生を選択させられます。iOS5からはエアプレイ再生はデフォルトで可能となっています。allowsAirPlayerをNOとすれば不可にできます。

もし、動画のビューを自分のビュー階層に組み込んで使いたい時は、必ずサイズを正しく設定してください。
最終更新:2013年01月25日 17:49