iOS 中流畅的视频循环播放

Smooth video looping in iOS(iOS 中流畅的视频循环播放)
本文介绍了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(出于其他原因),但这种方法会在循环之间产生大约一秒的明显停顿.

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

AWS DynamoDB Batch Get Request - iOS(AWS DynamoDB 批量获取请求 - iOS)
Querying DynamoDB on non-key attributes(在非关键属性上查询 DynamoDB)
DynamoDB auto incremented ID amp; server time (iOS SDK)(DynamoDB 自动递增 ID amp;服务器时间(iOS SDK))
Genymotion error after windows 10 upgrade(Windows 10 升级后 Genymotion 错误)
Where to find a clear explanation about swift alert (UIAlertController)?(哪里可以找到关于 swift alert (UIAlertController) 的清晰解释?)
Android - java.lang.IllegalArgumentException Erron when creating Dialog on 2.1 and low android(Android - java.lang.IllegalArgumentException 在 2.1 和低 android 上创建对话框时出错)