android – How to extract codec and bitrate from an internet stream using androidX media3 libraries?


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?



Source link

Leave a Comment