Search code examples
iphonecocoa-touchmpmovieplayercontrollermpmovieplayer

Playing subsequent movies in one MPMoviePlayerViewController


I am having a difficulty with the MPMoviePlayViewController. I insatiate the controller, assign the url and show the player using:

[self presentMoviePlayerViewControllerAnimated:[appDelegate movieController]];

Then when the movie finished I dismiss it:

[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];    
[self dismissMoviePlayerViewControllerAnimated];  

The movie player is alloc in my AppDelegate. There are some other listeners on MPMoviePlayerPlaybackDidFinishNotification. This is for the case where there might e.g. only be audio and it shows a play/pause button and counters in table cells.

The problem is that when I load a second movie in the same MPMovieViewController, it appears fine but the controls are not working correctly. They are work as long as they are visible, but as soon as they disappear there is no may of getting them back and therefore to dismiss the movie player.Sometimes closing and opening the App works, but sometimes it doesn't and I need to 'kill' the App in order to be able to start again.

Is there a way to play subsequent video's in the MoviePlayer while the controls still work? Any suggestions how to 'reset' the Player in a way that I can prevent the other listeners from given a DEALLOC as they are listening for the action?


Solution

  • you dont need to dismiss the player you just need to set the new url... or maybe I missunderstood your problem...

    Try adding this to your setup movie player controller

    moviePlayerController.view.userInteractionEnabled = YES;