ios4mpmovieplayercontrollerexit

How to programmatically exit a Movie Player?


I have a simple view with a button. When clicked it pops up movie player (Using the MoviePlayer.framework). I want to programmatically click the Done button or some how exit the movie player and return to previous view.

I can get a handle to movie player's window but how can I end it?


Solution

  • AHH, finally, i can help with something here:

    Ok, at first, when you create the player, you can assign yourself as an observer to MPMoviePlaybackDidFinishNotification. That means, when the "done" button or the movie is done playing, this notification is called out.

    So you now have to assign a method to be called by the notification center.

      [[NSNotificationCenter defaultCenter] 
       addObserver:self 
       selector:@selector(moviePlayBackDidFinish:)
       name:MPMoviePlayerPlaybackDidFinishNotification 
       object:player]; 

    Then all you need is to create the moviePlayBackDidFinish method and close the player from there. If you need more code, let us know.