How to get Sampling rate and frequency of music file (MP3) in android?

前端 未结 3 664
攒了一身酷
攒了一身酷 2020-12-05 11:50

I am developing audio player in android. So i want to add the details of the playing song i.e. Artist Name, Duration, Bit rate and sampling frequency. I can get Artist Name

3条回答
  •  独厮守ぢ
    2020-12-05 12:24

    You can approximate it by dividing the file size by the length of the audio in seconds, for instance, from a random AAC encoded M4A in my library:

    File Size: 10.3MB (87013064 bits)
    Length: 5:16 (316 Seconds)
    Which gives: 87013064 bits / 316 seconds = 273426.147 bits/sec or ~273kbps
    Actual Bitrate: 259kbps
    

    Since most audio files have a known set of valid bitrate levels, you can use that to step the bit rate to the appropriate level for display.

提交回复
热议问题