Testing MPMoviePlayerViewController in iPad simulator

Posted by hgpc on Stack Overflow See other posts from Stack Overflow or by hgpc
Published on 2010-05-11T16:35:43Z Indexed on 2010/05/11 17:24 UTC
Read the original article Hit count: 458

I have a view that shows a MPMoviePlayerViewController modally. When testing it in the iPad simulator it works well on the first try. If I dismiss the video and then show the view again, the player only plays the audio, but not the video.

Is this a simulator quirk or am I doing something wrong? Here's my code:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    MPMoviePlayerViewController* v = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
    [[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(playbackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:v.moviePlayer];
    [self presentMoviePlayerViewControllerAnimated:v];
    [v release];
}

-(void) playbackDidFinish:(NSNotification*)aNotification
{
    MPMoviePlayerController *player = [aNotification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:player];
    [player stop];
    [self dismissMoviePlayerViewControllerAnimated];
}

© Stack Overflow or respective owner

Related posts about ipad

Related posts about mpmovieplayercontroller