Tom Susel
Tom Susel

Reputation: 3437

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.

Upvotes: 2

Views: 1222

Answers (1)

Tom Susel
Tom Susel

Reputation: 3437

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.

Upvotes: 5

Related Questions