问题描述
有人可以建议一种方法,通过它可以在iOS中实现视频剪辑的完全平滑无缝循环吗?我尝试了两种方法,两种方法都会在视频循环时产生一个小暂停
Can anyone suggest a method by which you can achieve a completely smooth and seamless looping of a video clip in iOS? I have tried two methods, both of which produce a small pause when the video loops
1)AVPlayerLayer,其中playerItemDidReachEnd通知设置为seekToTime:kCMTimeZero
1) AVPlayerLayer with the playerItemDidReachEnd notification setting off seekToTime:kCMTimeZero
我更喜欢使用AVPlayerLayer(出于其他原因),但这种方法会在循环之间产生大约一秒钟的显着暂停。
I prefer to use an AVPlayerLayer (for other reasons), but this method produces a noticeable pause of around a second between loops.
2)带有setRepeatMode的MPMoviePlayerController:MPMovieRepeatModeOne
2) MPMoviePlayerController with setRepeatMode:MPMovieRepeatModeOne
这会导致较小的暂停,但仍然不完美。
This results in a smaller pause, but it is still not perfect.
我不知道从哪里开始。任何人都可以提出一个灵魂吗?
I'm not sure where to go from here. Can anyone suggest a soultion?
推荐答案
我可以同意@ SamBrodkin的调查结果。
I can concur @SamBrodkin's findings.
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(myMovieFinishedCallback:)
name: MPMoviePlayerPlaybackStateDidChangeNotification
object: m_player];
和
-(void) myMovieFinishedCallback: (NSNotification*) aNotification
{
NSLog( @"myMovieFinishedCallback: %@", aNotification );
MPMoviePlayerController *movieController = aNotification.object;
NSLog( @"player.playbackState = %d", movieController.playbackState );
}
为我修复了iOS 5上的非循环问题。
fixed the non-looping issue on iOS 5 for me too.
这篇关于在iOS中平滑视频循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!