开发者

How to know when the MPMoviePlayerController has been paused in iPhone?

I want to add an overlay view for my video when the video is paused by the user. Is there any way to get the pause notification from MPMoviePlayerController?

According to Apple Doc, there should be ways to do this but I can't find which notification should I use for this purpose.

Quote:

开发者_高级运维

In addition to being notified when playback finishes, interested clients can be notified in the following situations:

-When the movie player begins playing, is paused, or begins seeking forward ... For more information, see the Notifications section in this reference.


I assume you know about delegates and protocols as a means of receiving callbacks?

There's another global mechanism called notifications too.

You can do this via

[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(playbackStateChanged) 
    name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

Then, within playbackStateChanged, you can fetch the playbackState

 - (void) playbackStateChanged {

   _player.playbackState; // reading the playback

 }

The step of reading playbackstate directly from the player is specified in the docs

To get the current playback state, get the value of the playbackState property of the movie player object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜