获取本地mp3音频文件时长
<dependency> <groupId>org</groupId> <artifactId>jaudiotagger</artifactId> <version>2.0.1</version> </dependency>
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.mp3.MP3AudioHeader;
import org.jaudiotagger.audio.mp3.MP3File;
public static void main(String[] args) { try { MP3File f = (MP3File) AudioFileIO.read(new File("C:\\Desktop\\b4ef18fe62948ab2528127c8c1357ddd.mp3")); MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader(); System.out.println( audioHeader.getTrackLength()); } catch(Exception e) { e.printStackTrace(); } }