简体   繁体   English

如何知道AVPlayer何时使用纯音频比特率?

[英]How to know when AVPlayer uses the audio only bit-rate?

While streaming when encountering slow connectivity the AVPlayer may choose to play the lowest bit-rate in the HTTP Live Streaming playlist. 当流媒体遇到缓慢的连接性时,AVPlayer可能会选择播放HTTP Live Streaming播放列表中的最低比特率。

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. 我尝试通过KVO观察AVPlayerItem的“ tracks”属性,以查看何时仅包含音频,但是在大多数情况下,即使播放器切换到纯音频流,tracks属性也不会更改。

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). 我发现AVPlayerItem tracks属性不依赖于模拟器,而是更依赖于实际设备(偏差约5秒)。

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 to AVMediaTypeVideo . 每当tracks属性更改时(您可以通过KVO找出时间),都应该遍历该轨道,并查看是否有任何将'mediaType'设置为AVMediaTypeVideo If there are none then you can conclude that you are in an audio only state. 如果没有,则可以得出您处于仅音频状态的结论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM