views:

593

answers:

3

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 fromt 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.

Thanks, liam m-

A: 

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.

Seamus Campbell
Thanks for the reply, this is almost there. In order to get to the MPMoviePlayerController I had to cast it like this:[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:(MPMoviePlayerController *)[delegateMoviePlayer moviePlayer]];What I can see is that when I click on the next and previous buttons are a MPMoviePlaybackStateStopped playback state. That works and I'm getting notifications, I need to determine the difference between the previous and next button clicks. That would be the full solution.
Liam
Clarification: I am getting a MPMoviePlaybackStateStopped playback state but this is not the buttons and I seem to still have no way to tell what button was pressed.
Liam
You might add listeners for the other notifications defined in http://developer.apple.com/iphone/library/documentation/mediaplayer/reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html and see if any of them are firing when you click those buttons.
Seamus Campbell
Thanks Seamus, but it is starting to look like after crawling the documentation and a lto of sources that Apple does not notify us about the button events while in fullscreen mode. Per the documentation I can get info about the object sending the event as well as some user info, but nothing helping me to know if they clicked the next button or the previous button.To your point, I did initiate every listener available and crawled each NSNotification. Unless I'm really missing something there is no way to get info about the fullscreen view's controls for next and previous.
Liam
+1  A: 

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.

Seamus Campbell
Ack. You're developing for iPad... no iOS 4 yet.
Seamus Campbell
Yeah, but really, thanks for putting so much work into this one. I'll save this for when I'm ready for the iOS 4 and hopefully that will be the thing that lets me do this right.I've looked at the ABC app and they solved it with a custom view, so that is how I'm going to have to go with this as well. I was really hoping to avoid that since it just adds more time and more places for things to go wrong.How do I give you credit even though we don't have a final solution?
Liam
A: 

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

http://stackoverflow.com/questions/3593683/how-can-i-know-users-click-fast-forward-and-fast-rewind-buttons-on-the-playback-c/3598383#3598383

alones