Reputation: 515
I am using the AndroidX media3 component, and have it playing internet radio audio steams, (MP3/FLAC/HLS/MP4 etc). I would like to display codec and bitrates within the UI of my Android app, however I am having trouble finding where to even start with this, I have looked at the docs, and also looked at the interfaces available in my app, and not come up with very much at all.
The closest I have come to something is from the getAudioFormat interface that the player provides.
player.getAudioFormat().sampleMimeType
This works, and I can work out the codec type, however the following don't work, and always return -1
player.getAudioFormat().sampleRate
player.getAudioFormat().averageBitrate
player.getAudioFormat().bitrate
My question, I guess, is twofold:
1/ Am I approaching this problem correctly, as above, and if so, is this a bug, where the bitrates are not shown. 2/ If not, what is the correct way to achieve what I am trying to do?
Upvotes: 0
Views: 435
Reputation: 3871
You need to create AnalyticsListener
. You'll receive an onTracksChanged
event, it has Tracks
object with available tracks. Each track has a format and the format contains information about codecs.
https://developer.android.com/reference/androidx/media3/common/Format#codecs()
Upvotes: 0