English 中文(简体)
iOS多个AVPlayer对象导致音频/视频同步丢失
原标题:iOS Multiple AVPlayer objects results in loss of audio/video sync

我一直在尝试在我的应用程序中使用两个不同的AVQueuePlayer对象。第一个玩家通过网络播放一系列短视频片段。第二个对象只播放一个视频,但长度要长得多。它也是流式传输的。我已经验证了所有剪辑都有正确的音频/视频同步。

我注意到的是,如果我在预先创建了另一个AVPlayer对象之后创建了一个AVPlayer对象,则第二个播放器中的音频/视频同步将丢失。音频播放在800米到1500米之间太早了。

我尝试了很多方法,包括在清理第一个播放器和分配第二个播放器之间增加延迟,删除对AudioSession代码的所有调用等。这些似乎都没有帮助。音频偶尔会同步,但实际上只发生30次中的1次。

有其他人看到过同样的行为吗?有人知道怎么解决这个问题吗?

感谢任何能提供帮助的人!

问题回答

我自己也面临着同样的问题。我在AVPlayerLayer文档中发现了一些信息:

During playback, AVPlayer may compensate for temporal drift between its visual output and its audible output to one or more independently-clocked audio output devices by adjusting the timing of its associated player layers. The effects of these adjustments are usually very small; however, clients that wish to remain entirely unaffected by such adjustments may wish to place other layers for which timing is important into independently timed subtrees of their layer trees.

You can create arbitrary numbers of player layers with the same AVPlayer object. Only the most-recently-created player layer will actually display the video content on-screen.

不幸的是,我还没有把它破译成实际的代码,但我认为它可能有助于为你指明正确的方向。如果你真的想出了解决方案,请把它发布在这里,我也会这么做。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。