What is the default buffer size for AVPlayer?

What is the maximum and minimum default buffer size for iOS AVPlayer? How to increase its size for mp3 streaming? thanks

+6
source share
1 answer

If your buffer size means a playback buffer, I believe this size is undocumented.

This behavior is provided by AVFoundation, indicated on Achievements in AVFoundation Playback

And we see that playback starts, but then we quickly go to the stall because we did not have enough buffer to play to the end.

In this case, we will go into the standby state and re-buffer until we have enough to play.

They simply mentioned a rather inaccurate time or size, it makes sense, which is a dynamic unit of measure in accordance with the current network situation, but who knows.

Return to the topic if you want to take control of buffering. You can observe the AVPlayerItem loadedTimeRanges property.

below the code snippet was a 5 second buffer time:

 if ([keyPath isEqualToString:@"loadedTimeRanges"]) { NSArray *timeRanges = (NSArray *)[change objectForKey:NSKeyValueChangeNewKey]; if (timeRanges && [timeRanges count]) { CMTimeRange timerange = [[timeRanges objectAtIndex:0] CMTimeRangeValue]; if (self.audioPlayer.rate == 0 && !pauseReasonForced) { CMTime bufferdTime = CMTimeAdd(timerange.start, timerange.duration); CMTime milestone = CMTimeAdd(self.audioPlayer.currentTime, CMTimeMakeWithSeconds(5.0f, timerange.duration.timescale)); if (CMTIME_COMPARE_INLINE(bufferdTime , >, milestone) && self.audioPlayer.currentItem.status == AVPlayerItemStatusReadyToPlay && !interruptedWhilePlaying && !routeChangedWhilePlaying) { if (![self isPlaying]) { [self.audioPlayer play]; } } } } } 
+1
source

Source: https://habr.com/ru/post/974067/


All Articles