我只想要一个连续循环的视频。我这样设置播放器:
self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:someURL];
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.moviePlayer.shouldAutoplay = YES;
self.moviePlayer.repeatMode = MPMovieRepeatModeOne;
self.moviePlayer.view.frame = self.container.frame;
[self.container addSubview:self.moviePlayer.view];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(moviePlayBackDidFinish:) name: MPMoviePlayerPlaybackStateDidChangeNotification
object: self.moviePlayer];
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
NSLog( @"myMovieFinishedCallback: %@", notification );
MPMoviePlayerController *movieController = notification.object;
NSLog( @"player.playbackState = %d", movieController.playbackState );
}
通知方法只是有人在这里建议的一种技巧:iOS 中的平滑视频循环
我有两个问题。视频循环仍然不是无缝的。循环之间有一个非常明显的停顿。其次,视频在任意循环次数后停止循环。通常在 2-4 个循环之间变化。这显然是我的应用程序的一个大问题。播放器真的有这么多问题还是我做错了什么?