微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/iOS/334579.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐