If I load an AVPlayer
with a file from a host with
[AVPlayer playerWithPlayerItem:playerItem];
And the "buffering" takes longer than the user wants, how do I allow them to cancel it?
So the correct answer is @Che with:
If you will call [self.player replaceCurrentItemWithPlayerItem:nil]; buffering stops. – Che Oct 13 at 14:36
and you do so on the observer listening for the status update from the playerWithPlayerItem. Thanks All!
you can try this
// pause buffer
[self.playerItem cancelPendingSeeks];
[self.playerItem.asset cancelLoading];
I don't think there is a method to directly stop buffering. But you can check the boolean playbackLikelyToKeepUp
property of the AVPlayerItem to check if the buffer is loading. I not then pause playback on the AVPlayer.
Swift 3
player?.replaceCurrentItem(with: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With