0

I am using the following to play a video named intro

- (IBAction)PlayIntro:(id)sender {
    NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"intro" ofType:@"m4v"];
    introplayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:videoPath]];
    [self presentMoviePlayerViewControllerAnimated:introplayer];
}

I am having trouble setting up a notification so that once the video is finished playing the following would take place [self performSegueWithIdentifier:@"IntroS" sender:sender]; any help would be appreciated.

Emil
  • 7,220
  • 17
  • 76
  • 135

1 Answers1

0

You should set up KVO for your MPMoviePlayerController. When the state of the movie changes, this fires giving you a chance to compare total playback time with the current playback time.

Given your snippet of code, this line will give you the current playback value:

NSLog(@"Movie player state: %g", introplayer.currentPlaybackTime);

I provided a brief overview on how KVO works with an example unrelated to video playback.

Though the topic is unrelated to video, it works just the same regardless of what variable you're watching using KVO.

Community
  • 1
  • 1
Alex Smith
  • 468
  • 5
  • 22