repeatmode doesn't work in MPMoviePlayerViewController?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 08:08:18

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];

you can try this code

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!