How to get the size and duration of an mp3 file?

前端 未结 6 887
夕颜
夕颜 2021-01-12 07:13

I need to calculate the total length of an mp3 file.

Currently I am using a PHP class which I found @ http://www.zedwood.com/article/php-calculate-duration-of-mp3.

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 07:19

    A Famous and Very SPI that you can use MP3 SPI and the code is also very simple

    File file = new File("filename.mp3");
    AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(file);
    Map properties = baseFileFormat.properties();
    Long duration = (Long) properties.get("duration");
    

提交回复
热议问题