我遇到了MPMoviePlayerViewController的问题,它的属性是repeatMode。据说将其设置为MPMovieRepeatModeOne值将导致播放器重复播放。我使用以下代码在循环中播放视频,但它只是在结束后停止。
MPMoviePlayerViewController *mpViewController =[[MPMoviePlayerViewController alloc] init];
mpViewController.moviePlayer.contentURL= movieURL;
self.aPlayer=mpViewController;
self.aPlayer.moviePlayer.repeatMode=MPMovieRepeatModeOne;
答案 0 :(得分:1)
mpViewController.repeatMode=MPMovieRepeatModeOne;
为我工作,但我没有网址或自我。
我在上面的下一行是[mpViewController play];
答案 1 :(得分:1)
删除此行
[self.aPlayer.moviePlayer setRepeatMode:MPMovieRepeatModeOne];
并提出:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerDidChangeState:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:self.player];
并实施
- (void)moviePlayerDidChangeState:(NSNotification *)note
{
MPMoviePlaybackState playbackState = [self.player playbackState];
if(playbackState==MPMoviePlaybackStateStopped ||playbackState==MPMoviePlaybackStatePaused || playbackState==MPMoviePlaybackStateInterrupted)
{
if (note.object == self.player) {
NSInteger reason = [[note.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue];
if (reason == MPMovieFinishReasonPlaybackEnded)
{
[self.player play];
}
}
}
}