gpt4 book ai didi

buffer - AVPlayer 的默认缓冲区大小是多少?

转载 作者:行者123 更新时间:2023-12-04 15:57:37 38 4
gpt4 key购买 nike

iOS AVPlayer 的默认最大和最小缓冲区大小是多少?如何增加 mp3 流媒体的大小?谢谢你

最佳答案

如果您的 缓冲区大小 意味着播放缓冲区,那么我相信这个大小没有记录。
此行为由 AVFoundation 提供,引用于 Advances in AVFoundation Playback

And we see that playback starts but then we quickly run into a stall because we didn't have enough buffer to play to the end.

In that case, we'll go into the waiting state and re-buffer until we have enough to play through.


他们刚刚提到 够了不是确切的时间或大小,它是根据当前网络情况的动态度量单位,但谁知道呢。
回到主题,如果您想控制缓冲。
您可以关注 AVPlayerItemloadedTimeRanges属性(property)。
下面的代码片段有 5 秒的缓冲时间:
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];
}
}
}
}
}

关于buffer - AVPlayer 的默认缓冲区大小是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25397719/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com