IOS AVPlayer cancels buffering

If I download an AVPlayer file from the host with

 [AVPlayer playerWithPlayerItem:playerItem]; 

And "buffering" takes longer than the user wants, how can I let them cancel it?

+4
source share
5 answers

So the correct @Che answer:

If you call [self.player replaceCurrentItemWithPlayerItem: nil]; buffering stops. - Che October 13 at 2:36 pm

and you do it on an observer, listening to the status update from playerWithPlayerItem. Thanks everyone!

+7
source

I do not think there is a method to stop the buffering stop. But you can check the boolean playbackLikelyToKeepUp property for the AVPlayerItem object to check if the buffer is loaded. I do not pause playback on AVPlayer.

+1
source

Swift 3

 player?.replaceCurrentItem(with: nil) 
+1
source

you can try this

 // pause buffer [self.playerItem cancelPendingSeeks]; [self.playerItem.asset cancelLoading]; 
0
source

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

 self.avPlayer.currentItem.preferredForwardBufferDuration = 1; 

From Apple documentation: This property determines the preferred forward buffer duration in seconds. If set to 0, the player will select the appropriate buffering level for most use cases. Setting this property to a low value will increase the likelihood that playback will stop and re-buffer, and setting it to a high value will increase the demand for system resources.

0
source

All Articles