3

I'm using AVPlayer to play video. I use AVPlayer pause to pause the player. But observing with Charles shows that the stream segments are still being downloaded when the player is in paused state.

I found AVPlayer buffering, pausing notification, and poster frame but they said it was

AVPlayer will buffer the video in several cases, none cleary documented

Is this normal behavior? How to make buffering pause when player pauses?

Community
  • 1
  • 1
onmyway133
  • 45,645
  • 31
  • 257
  • 263
  • 3
    Checkout `canUseNetworkResourcesForLiveStreamingWhilePaused` in [iOS 9](https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVPlayerItem_Class/index.html#//apple_ref/occ/cl/AVPlayerItem). – Anurag Sep 08 '15 at 02:58
  • canUseNetworkResourcesForLiveStreamingWhilePaused should be ok according to documentation, but it doesn't work in my case. – DixieFlatline Jun 22 '16 at 09:23

1 Answers1

0

You need to manage preferredForwardBufferDuration of avplayer currentItem. If you want to stop buffering set value to 1 because if you set it to 0 it will be set up automatically

self.avPlayer.currentItem.preferredForwardBufferDuration = 1;

From Apple documentation: This property defines the preferred forward buffer duration in seconds. If set to 0, the player will choose an appropriate level of buffering for most use cases. Setting this property to a low value will increase the chance that playback will stall and re-buffer, while setting it to a high value will increase demand on system resources.