2015-08-26 137 views
3

我正在使用AVPlayer播放视频。我使用AVPlayer pause来暂停播放器。但与Charles一起观察显示,播放器处于暂停状态时,流段仍在下载。如何强制AVPlayer在暂停状态时暂停缓冲?

我发现AVPlayer buffering, pausing notification, and poster frame但他们说这是

AVPlayer将缓冲视频在若干情况下,没有克利 记录

这是正常的行为呢?玩家暂停时如何缓冲暂停?

+3

在[iOS 9]中签出'canUseNetworkResourcesForLiveStreamingWhilePaused'(https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVPlayerItem_Class/index.html#//apple_ref/occ/cl/AVPlayerItem )。 – Anurag

+0

根据文档,canUseNetworkResourcesForLiveStreamingWhilePaused应该没问题,但在我的情况下不起作用。 – DixieFlatline

回答

0

您需要管理avplayer currentItem的preferredForwardBufferDuration。如果你想停止缓冲设定值1,因为如果你将它设置为0它会自动

self.avPlayer.currentItem.preferredForwardBufferDuration = 1; 

建立来自苹果文档:此属性定义以秒为首选前锋缓冲时间。如果设置为0,玩家将为大多数使用情况选择适当的缓冲级别。将此属性设置为较低值会增加播放停顿和重新缓冲的几率,而将其设置为较高值会增加对系统资源的需求。