repeatmode在MPMoviePlayerViewController中不起作用吗? [英] repeatmode doesn't work in MPMoviePlayerViewController?

查看:100
本文介绍了repeatmode在MPMoviePlayerViewController中不起作用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何像Vine Application中那样以n次重复显示录制的视频.

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

在这里,我使用MPMoviePlayerViewController,并且可以很好地显示录制的视频.但是问题是,它不会重复出现.

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

当前使用的代码是

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代码,

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..

注意: 我正在使用XCode 4.5.2工具和ios仿真器6.0

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

推荐答案

尝试此代码.它正在工作.

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

这篇关于repeatmode在MPMoviePlayerViewController中不起作用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆