modo de repetición no funciona en MPMoviePlayerViewController?

How to display a recorded video as repeat as an'n' number of times like in Vine Application.

Here I use the MPMoviePlayerViewController, and works great display the recorded video. But the problem is, it doesn't repeating.

Here the currently using code is,

NSURL *url = [NSURL fileURLWithPath:videoPath];
playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];

[self presentMoviePlayerViewControllerAnimated:playerController];
[playerController.moviePlayer prepareToPlay];

playerController.view.frame = CGRectMake(200, 402, 300, 200);
playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
playerController.moviePlayer.controlStyle = MPMovieControlStyleNone;
playerController.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
playerController.moviePlayer.repeatMode = MPMovieRepeatModeOne;
[self.view addSubview: playerController.view];
[playerController.moviePlayer play];

NSLog(@"repeatMode: %d",playerController.moviePlayer.repeatMode);
[playerController.view addSubview:customview];

[[NSNotificationCenter defaultCenter] addObserver:self
                                           object:[playerController moviePlayer]];

And the NSNotification code,

 - (void) movieFinishedCallback:(NSNotification*) aNotification
    NSLog( @"myMovieFinishedCallback: %@", aNotification );
    MPMoviePlayerController *movieController = aNotification.object;
    NSLog( @"player.playbackState = %d", movieController.playbackState );

Can anyone please give the solution..

Note: I'm using the XCode 4.5.2 tool and ios simulater 6.0

preguntado el 09 de septiembre de 13 a las 21:09

Anybody provide suggestion for how to display video as with repeat format? -

I see the post where you found this, and I don't know the solution. I don't see how simply logging the mp state will help. I guess the first thing I'd try is [movieController prepareToPlay] or [movieController stop] to reset the playhead then [movieController play]. But I really am not sure. -

@raman : take a look at my answer hopefully it will help you to achieve your output. -

3 Respuestas

Try this code. It is working.

    NSURL *fileUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Video" ofType:@"mp4"]];
    MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc]initWithContentURL:fileUrl];
    [moviePlayerController.moviePlayer prepareToPlay];
    [moviePlayerController.moviePlayer setRepeatMode:MPMovieRepeatModeOne];
    [moviePlayerController.moviePlayer setControlStyle:MPMovieControlStyleEmbedded];
    [self.view addSubview:moviePlayerController.view];

Respondido el 10 de Septiembre de 13 a las 07:09

puedes probar este código

-(void) movieFinishedCallback:(NSNotification *) aNotification
    if (aNotification.object == self.moviePlayer) {
        NSInteger reason = [[aNotification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue];
        if (reason == MPMovieFinishReasonPlaybackEnded)
            [playerController play];

Respondido el 10 de Septiembre de 13 a las 05:09

You have to keep the MPMoviePlayerController object as a member, otherwise the app would lose context to it and the movie will not loop.

Respondido el 28 de diciembre de 14 a las 17:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.