如何知道 AVPlayer 何时使用纯音频比特率?
在进行流式传输时,如果连接速度较慢,AVPlayer 可能会选择播放 HTTP 实时流媒体播放列表中的最低比特率。
有没有办法识别这种转变?
我尝试通过 KVO 观察 AVPlayerItem“tracks”属性,以查看它何时仅包含音频,但在大多数情况下,即使播放器切换到仅音频流,tracks 属性也不会更改。
While streaming when encountering slow connectivity the AVPlayer may choose to play the lowest bit-rate in the HTTP Live Streaming playlist.
Is there a way to identify this transition?
I've tried observing the AVPlayerItem "tracks" property via KVO to see when it contains only audio but in most cases the tracks property isn't changed even though the player switched to the audio only stream.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现
AVPlayerItem
tracks
属性不依赖于模拟器,但在某种程度上更依赖于实际设备(有约 5 秒的偏差)。每当
tracks
属性发生变化时(您可以通过 KVO 找到),您应该遍历轨道并查看是否有任何“mediaType”设置为AVMediaTypeVideo
的轨道。如果没有,那么您可以断定您处于纯音频状态。
I found out that the
AVPlayerItem
tracks
property was not dependable on the simulator but somewhat more dependable on the actual device (with a ~5 seconds deviation).Whenever the
tracks
property changes (you can find out when via KVO) you should traverse the tracks and see if there are any tracks with 'mediaType' set toAVMediaTypeVideo
.If there are none then you can conclude that you are in an audio only state.