AVPlayer流式传输进度 [英] AVPlayer streaming progress

查看:95
本文介绍了AVPlayer流式传输进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功使用 AVPlayer 从服务器传输音频,我现在要做的是显示自定义 UISlider 谁显示缓冲的进度。

I'm successfully using AVPlayer to stream audio from a server and what I want to do now is to show a custom UISlider who shows the progress of the buffering.

这样的事情:

使用 AVPlayer 似乎没有办法获得音频文件的总下载大小或当前下载量,只有当前播放时间和总播放时间。

With AVPlayer there doesn't seem to be a way to get the total download size or the current downloaded amount for the audio file, only the current playing time and total play time.

这有什么变通方法吗?

推荐答案

我正在研究这个问题,到目前为止还有以下几点:

I am just working on this, and so far have the following:

- (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;
}

这篇关于AVPlayer流式传输进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆