0

Vine アプリケーションのように、録画したビデオを n 回繰り返して表示する方法。

ここでは MPMoviePlayerViewController を使用し、録画したビデオをうまく表示します。しかし問題は、それが繰り返されないことです。

ここで、現在使用しているコードは、

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
                                         selector:@selector(movieFinishedCallback:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:[playerController moviePlayer]];

そして NSNotification コード、

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

誰でも解決策を教えてください..

注: XCode 4.5.2 ツールと iOS シミュレーター 6.0 を使用しています。

4

3 に答える 3

0

このコードを試すことができます

-(void) movieFinishedCallback:(NSNotification *) aNotification
{
    if (aNotification.object == self.moviePlayer) {
        NSInteger reason = [[aNotification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue];
        if (reason == MPMovieFinishReasonPlaybackEnded)
        {
            [playerController play];
        }
    }
}
于 2013-09-10T04:37:33.243 に答える