soleil
soleil

Reputation: 13085

Change content of MPMoviePlayerController

When I attempt the following, the video that is currently playing stops when double-tapped, but the new video doesn't play. I just get a black screen.

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tap.numberOfTapsRequired = 2;
[self.moviePlayer.view addGestureRecognizer:tap];


- (void)handleTap:(UITapGestureRecognizer *)gesture {

    NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"Movie2" ofType:@"mp4"];


    [self.moviePlayer setContentURL:[NSURL fileURLWithPath:moviePath]];
    NSLog(@"contentURL: %@", self.moviePlayer.contentURL);
}

The log statement correctly shows file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/15072262-7BC0-42D5-840C-740CF5B97D55/MyApp.app/Movie2.mp4

Movie2.mp4 is valid and plays if I set it as the contentURL when I first create the MPMoviePlayerController. Why can't I change the content of the player?

Upvotes: 0

Views: 932

Answers (1)

soleil
soleil

Reputation: 13085

Actually I just had to tell it to play after changing the contentURL: [self.moviePlayer play];

Upvotes: 2

Related Questions