开发者

How do I catch the MPMoviePlayer next button click event while in fullscreen mode on the iPad?

When the MPMoviePlayerViewController is in fullscreen mode on the iPad, it defaults to having its controls to have a previous and next button on the overlay there. In my project I need to capture the click for that overlay button and handle it accordingly. Since I'm not sure how to invoke a playlist just yet there is no next item and clicking on the button breaks the view 开发者_运维问答once I exit fullscreen mode. Somehow it just doesn't know what to do and I get no errors.

What I would like to know is if there a way to listen/catch that event from the fullscreen next and previous buttons?

I have also tried to get an overlay with my own controls to live on the MPMoviePlayer, MPMoviePlayerController, and the MPMoviePlayerViewController with no success. Once the player enters fullscreen mode any overlay that was present is ignored and not carried along with the screen zooming.

Is there a reliable way to have an overlay while in fullscreen mode? I have looked at the sample from Apple but this seems to not work for me to actually add anything to the view while in fullscreen mode.

Any help would be appreciated.


I haven't used MPMoviePlayerViewController, but here are some thoughts based on peeking at the documentation.

It looks like the MPMoviePlayerController has some notifications that might be relevant, though I don't see specific references to "next and previous buttons". Might they be Seek buttons?

Register for the notification with

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

And add this function to your object:

-(void)moviePlayerPlaybackStateChanged:(NSNotification *)notification {
    MPMoviePlayerController *moviePlayer = notification.object;
    MPMoviePlaybackState playbackState = moviePlayer.playbackState;
    // ...
}

I suspect you'll find that you're getting MPMoviePlaybackStateSeekingForward and ...SeekingBackward updates for those buttons.


Here's another possibility I just stumbled across. The MPMoviePlayerController in full-screen mode may be sending Remote Control events. Catch these (iOS 4 only, by the way) by enabling remote control event messages in your view controller:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

and then implement

[UIResponder remoteControlReceivedWithEvent:(UIEvent*)event];

and when the view goes away, unregister in viewWillDisappear:

[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];

I'm not certain that this will work, but it's worth a shot.


Seaamsu Campbell is right :) Using his approach I got events of playback control events. See my question and answer.

How can I know users click fast forward and fast rewind buttons on the playback controls in iPhone

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜