ios – AVPlayer / AVPlayerItem的缓冲区大小

我正在为iOS创建流媒体广播应用程序,我想调整AVPlayer和AVPlayerItem的属性,以便在有损连接条件下让我更可靠地播放.
我想增加buffersize.

我能找到的唯一答案是here

无论如何要实现这一目标而不去OpenAL?

解决方法

在您的观察者方法中添加以下代码.
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
}

我已经实施并且运作良好.

参考自:https://stackoverflow.com/a/7730708/2315453

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...