tags:

views:

312

answers:

2

I am creating an iPad add and I am using a MPMoviePlayerViewController to playback a video.

The video is occupying the entire iPad screen like this.

playerViewController.view.frame = self.view.frame;

I need a way for the user to be able to press a button to go to a different screen.

I notice that automagically a done button appears in the nav controller when I create a MPMoviePlayerViewController.

My questions:

a.) Is there anyway to hook into the existing done button? Basically I just want to dismiss the view controller.

b.) If that won't work. How can I add my own custom button? As I mentioned above, the MPMoviePlayerViewController is occupying the entire screen. One idea I had was to create the MPMoviePlayerViewController in a frame and leave a bit of vertical space so I could add my own tool bar.

I would prefer suggestions on how to implement a.)?

If that is not possible, maybe some suggestions on how dismiss the MPMoviePlayerViewController by way of some button press?

All help appreciated.

+1  A: 

From the docs:

the Done button causes movie playback to pause while the player transitions out of fullscreen mode. If you want to detect this scenario in your code, you should monitor other notifications such as MPMoviePlayerDidExitFullscreenNotification.

So, try observing this notification:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayerDidExitFullscreen:)
                                             name:MPMoviePlayerDidExitFullscreenNotification
                                           object:nil];

And later:

- (void)moviePlayerDidExitFullscreen:(NSNotification *)theNotification {
    // do whatever you need to...
}

Edit: I think I misread your question. What you want is the method
-dismissMoviePlayerViewControllerAnimated

I assume you're presenting it using -presentMoviePlayerViewControllerAnimated:? You can add a button using moviePlayer.navigationItem.rightBarButtonItem (or left, or whichever). Set this button's target to your view controller, and intercept that action to call -dismiss...

jtbandes
I really just need a way to allow the user to close the ViewController. In fact, I just want to:[self dismissModalViewControllerAnimated:YES];I tried registering for MPMoviePlayerDidExitFullscreenNotification which works fine but does not have the desired effect.Ideas?
butchcowboy
I tried adding a button and then assigning to mp.navigationitem.rightBarButtonItem but it did not show up. Does anyone have an example of this working?
butchcowboy
Anyone found a solution for this ? Been googling everywhere...How can I listen to the modal view being dismissed aprt from extending the controller and overriding the dissmiss method?
A: 

Hello it can be done using what jbandes said

[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(playbackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMoviePlayer.moviePlayer];