我已经成功地使用AVPlayer
从服务器流音频,现在我想要做的是显示一个自定义的UISlider
,该人可以显示缓冲的进度。
像这样的东西:
使用AVPlayer
似乎无法获得音频文件的总下载大小或当前下载量,只有当前播放时间和总播放时间。
有什么解决方法吗?
最佳答案
我正在为此工作,到目前为止有以下内容:
- (NSTimeInterval) availableDuration;
{
NSArray *loadedTimeRanges = [[self.player currentItem] loadedTimeRanges];
CMTimeRange timeRange = [[loadedTimeRanges objectAtIndex:0] CMTimeRangeValue];
Float64 startSeconds = CMTimeGetSeconds(timeRange.start);
Float64 durationSeconds = CMTimeGetSeconds(timeRange.duration);
NSTimeInterval result = startSeconds + durationSeconds;
return result;
}
关于iphone - AVPlayer流媒体进度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7691854/