Ok, so I’m currently updating an application for work and am getting some strange behavior with MPMoviePlayerController when trying to stream video. The problem is:
When the user presses the “Done” button on the player during the buffering stage (right after it finishes saying “loading video…” but before the video starts playing), the player hides and the audio (for the video) begins to play in the background. At this point, there are 3 ways for it to stop.
- Start playing another video
- Press the home button and exit the app
- Wait for the video to finish playing
Here is my code for playing the video.
-(void)playMovieAtURL:(NSURL*)theURL { MPMoviePlayerController* theMovie = [[MPMoviePlayerController alloc] initWithContentURL:theURL]; theMovie.scalingMode = MPMovieScalingModeNone; theMovie.movieControlMode = MPMovieControlModeDefault; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; [theMovie play]; } -(void)myMovieFinishedCallback:(NSNotification*)aNotification { MPMoviePlayerController* theMovie = [aNotification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; [theMovie release]; } |
Is this a 3.0 issue or am I doing something dumb? I have sent a support ticket to Apple and will post a solution if I find one. Please let me know in the comments if you are having the same issue and how you solved it (if you did).
Happy iCoding!