获取本地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(); } }

  

posted @ 2020-06-18 11:38  Ayan_ayan  阅读(631)  评论(0编辑  收藏  举报