AVPlayer未同步 [英] AVPlayer not synchronized

查看:209
本文介绍了AVPlayer未同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的没有想法,所以我不得不再问你们......

I'm really out of ideas so I'll have to ask you guys again...

我正在构建一个使用三个实例的iPhone应用程序AVPlayer。他们都在同一时间玩,他们这样做非常重要。我曾经运行过这段代码:

I'm building an iPhone application which uses three instances of AVPlayer. They all play at the same time and it's very important that they do so. I used to run this code:

CMClockRef syncTime = CMClockGetHostTimeClock();
CMTime hostTime = CMClockGetTime(hostTime);
[self.playerOne setRate:1.0f time:kCMTimeInvalid atHostTime:hostTime];
[self.playerTwo setRate:1.0f time:kCMTimeInvalid atHostTime:hostTime];
[self.playerThree setRate:1.0f time:kCMTimeInvalid atHostTime:hostTime];

完美无缺。但是几天前它刚停止工作,三个玩家被推迟了大约300-400ms(这是很多,100ms以下的一切都没问题)。其中两个AVPlayer有一些音频处理,比普通AVPlayer需要花费一些时间,但之前它曾经工作过,而且currentTime属性告诉我,这些播放器都被延迟了,所以同步似乎失败了。

which worked perfectly. But a few days ago it just stopped working, the three players are delayed by about 300-400ms (which is way to much, everything under 100ms would be okay). Two of these AVPlayer have some Audio processing, which takes some time more than the "normal" AVPlayer, but it used to work before and the currentTime property tells me, that these players are delayed, so the syncing seems to fail.

我不知道为什么它停止工作,我没有真正改变一些东西,但我正在使用一个观察者,我可以问一下self.playerX.currentTime属性,它给出了我延迟了大约.3 - .4秒......如果延迟> .1f,我已经尝试重新同步玩家,但延迟仍在那里。所以我认为播放器1和2的音频处理不能对延迟负责,因为currentTime属性确实知道它们被延迟了(我希望你知道我的意思)。也许你们中的某些人知道为什么我会有这么可怕的延迟,或者能够给我另一个想法。

I have no idea why it stopped working, I didn't really changed something, but I'm using an observer where i can ask the self.playerX.currentTime property, which gives me a delay of about .3-.4 seconds... I already tried to resync the players if delay>.1f but the delay is still there. So I think the audio processing of player1 and 2 can't be responsable for the delay, as the currentTime property does know they are delayed (i hope you know what I mean). Maybe someone of you guys know why I'm having such a horrible delay, or is able to provide me another idea.

提前致谢!

推荐答案

所以,我找到了解决方案。我忘了[self.playerX prerollAtRate:]。我想如果观察者是AVPlayerReadyToPlay则意味着玩家真的准备好了。事实上,它没有。在AVPlayer readyToPlay之后,它必须预先滚动。完成后,您可以同步您的布局器。延迟现在是0.000006秒。

So, I found the solution. I forgot to [self.playerX prerollAtRate:]. I thought if the observer is AVPlayerReadyToPlay it means, that the player is "really" ready. In fact, it does not. After AVPlayer is readyToPlay, it has to be pre rolled. Once that is done you can sync your placer. The delay is now somewhere at 0.000006 seconds.

这篇关于AVPlayer未同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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