Question

Im wanting to play a .mov file once through and then straight after play a second .mov file that is on repeat. Ive tried using sleeps and timers, as well as the AVqueue player and I just cant get any of them working. Is there a way to play a video after another using playbackState or duration times?

I'm using the MPMoviePlayer to do both of them as follows (nothing complicated)..

    NSString *stringPath1 = [[NSBundle mainBundle] pathForResource:@"Movie1" ofType:@"mov"];
    NSURL *url1= [NSURL fileURLWithPath:stringPath1];
    mpc = [[MPMoviePlayerController alloc] initWithContentURL:url1];
    [mpc setMovieSourceType:MPMovieSourceTypeFile];

    mpc.controlStyle = MPMovieControlStyleNone;
    mpc.view.frame = CGRectMake(-200, 100, 1152, 600);

    mpc.repeatMode = MPMovieRepeatModeNone;

    [self.view addSubview:mpc.view];
    [mpc play];


    NSString *stringPath2 = [[NSBundle mainBundle] pathForResource:@"Movie2" ofType:@"mov"];
    NSURL *url2= [NSURL fileURLWithPath:stringPath2];
    mpc2 = [[MPMoviePlayerController alloc] initWithContentURL:url2];
    [mpc2 setMovieSourceType:MPMovieSourceTypeFile];

    mpc.controlStyle = MPMovieControlStyleNone;
    mpc.view.frame = CGRectMake(-200, 100, 1152, 600);

    mpc.repeatMode = MPMovieRepeatModeOne;

    [self.view addSubview:mpc.view];
    [mpc play];

What can I put in between these bits of code so that the second movie only loads after the first one has played through?

Thanks.

Was it helpful?

Solution

You should try MPMoviePlayerPlaybackStateDidChangeNotification register for this notification , add an observer and once you receive notification you can play next movie.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top