简体   繁体   中英

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.

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.

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 to AVMediaTypeVideo . If there are none then you can conclude that you are in an audio only state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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