使用AVPlayer获取HTTP live stream audio文件的duration
来源:互联网 发布:pdfobject.js 兼容ie 编辑:程序博客网 时间:2024/04/19 12:10
关于AVPlayer的详细解析,请看Apple document。但是document里面并没有详细解析如何获取HTTP live stream文件的duration,google了一下,发现通过duration属性获取的方法,不能得到正确的直。正确的做法应该是通过调用AVPlayerItem的seekableTimeRanges来获取(loadedTimeRagnes表示已经下载的部分)。
事例代码如下:
[self.player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(2, 1) queue:nil usingBlock:^(CMTime time){ AVPlayerItem* currentItem = self.player.currentItem; NSArray* loadedRanges = currentItem.seekableTimeRanges; if (loadedRanges.count > 0) { CMTimeRange range = [[loadedRanges objectAtIndex:0] CMTimeRangeValue]; Float64 duration = CMTimeGetSeconds(range.start) + CMTimeGetSeconds(range.duration); NSLog(@"duration:%g", duration); CMTime currentTime = self.player.currentItem.currentTime; self.slider.value = CMTimeGetSeconds(currentTime) / duration; } }];
- 使用AVPlayer获取HTTP live stream audio文件的duration
- Apple http live stream
- Stream live media (HTTP)
- http live stream相关
- HTML5 更改audio src路径后,获取duration为NaN的解决方法
- 苹果上的Http Live Stream(HLS)技术初探
- AVI audio frame duration
- Stream live media (HTTP) -- using FMS
- AVPlayer的使用
- AVPlayer的基本使用
- AVPlayer的基本使用
- AVPlayer的基本使用
- AVPlayer的使用
- AVPlayer的基本使用
- AVplayer的使用教程
- AVPlayer的基本使用
- AVPlayer的使用
- 上传文件获取Stream的方法
- qt4 udp QUdpSocket -------wireshark
- C++0x FAQ中文版 - [C++11 FAQ]
- watir测试报告(二)
- 学长的工作初感受及对IT行业的理解====看来我只能把计算机当做工具
- Python对文件及文件夹的一些操作
- 使用AVPlayer获取HTTP live stream audio文件的duration
- 谈谈汽配的网络营销
- 关于Linux下kernel.shmmax的设置问题
- javascript线程解释(setTimeout,setInterval你不知道的事)
- Smarty总结:
- 前台绑定后台 DataTable 或 泛型 等
- MD5解密
- 冲动购物时代已过去
- 如何当好采购员