我正在为iOS创建一个流广播应用程序,我想调整AVPlayer和AVPlayerItem的属性,以便在有损连接情况下提供更可靠的播放。我想增加缓冲区大小。
我唯一能找到的答案是在这里
无论如何,是否有必要在不使用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
}
我已经实施并且工作良好。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句