在 iOS 中流畅的视频循环 [英] Smooth video looping in iOS

查看:27
本文介绍了在 iOS 中流畅的视频循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以提出一种方法,通过它您可以在 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(出于其他原因),但这种方法会在循环之间产生大约 1 秒的明显停顿.

I prefer to use an AVPlayerLayer (for other reasons), but this method produces a noticeable pause of around a second between loops.

2) 带有 setRepeatMode:MPMovieRepeatModeOne 的 MPMoviePlayerController

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 中流畅的视频循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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