我正在使用 MPMoviePlayerController 但我遇到的问题是它只重复两次但我必须不断重复它如何做到这一点请任何人建议我更好的方法。
-(void)viewDidLoad
{
player = [[MPMoviePlayerController alloc] initWithContentURL:outPutUrl];
player.view.frame = CGRectMake(0, 0, 320, 480);
player.repeatMode = MPMovieRepeatModeOne;
[player setShouldAutoplay:YES];
[player prepareToPlay];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player setControlStyle:MPMovieControlStyleNone];
[self.imgView addSubview:player.view];
[player play];
}
-(void)moviePlayerDidFinish:(NSNotification *)note
{
if (note.object == player)
{
NSLog(@"this is note%@",note.object);
NSInteger reason = [[note.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue];
if (reason == MPMovieFinishReasonPlaybackEnded)
{
[player play];
}
}
}