Buffer size for AVPlayer / AVPlayerItem

avaudioplayer, avplayer, ios, objective-c

Solution

Add the below piece of code in your observer method.

NSArray *timeRanges = (NSArray *)[change objectForKey:NSKeyValueChangeNewKey];
CMTimeRange timerange = [timeRanges[0] CMTimeRangeValue];

CGFloat smartValue = CMTimeGetSeconds(CMTimeAdd(timerange.start, timerange.duration));
CGFloat duration   = CMTimeGetSeconds(self.player.currentTime);
if(smartValue - duration > 5 || smartValue == duration) {
      // Change the value "5" to your needed secs, its the buffer size.
      // Play the video
}

I have implemented and works good.

Referred from : https://stackoverflow.com/a/7730708/2315453

Problem

I'm creating a streaming radio application for iOS and I would like to tweak the properties of AVPlayer and AVPlayerItem to give me more reliable playback in lossy connectivity conditions. I would like to increase the buffersize. The only answer I could find is here Is there anyway to achieve this without going to OpenAL?

Original source

Related problems