larsdroid / mp3-vbr-length

Calculate the length of MP3 files stored with a variable bitrate.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MP3 VBR Length

MP3 VBR Length is a Java library that can be used to calculate the length, in seconds, of an MP3 file stored with a variable bit-rate.

The code based in part on MP3Info version 0.8.5a by Cedric Tefft.

Download

Setup

Add the repository to your build.gradle:

repositories {
    maven {
        url "https://dl.bintray.com/larsdroid/mp3-vbr-length"
    }
}

Add the depencency to your build.gradle:

compile 'org.willemsens:mp3-vbr-length:1.0'

Usage

try {
    // Using NIO:
    final Path songPath = Paths.get("song.mp3");
    Mp3Info songInfo = Mp3Info.of(songPath);
    int songLengthSeconds = songInfo.getSeconds();
    
    // Using Java classic IO:
    final File songFile = new File("song.mp3");
    songInfo = Mp3Info.of(songFile);
    songLengthSeconds = songInfo.getSeconds();
} catch (IOException e) {
    // Handle exception
}

Please note that calling the Mp3Info::of method is a lengthy operation since the entire file is scanned.

Author

Lars Willemsens (https://github.com/larsdroid)

Original authors of MP3Info:
http://ibiblio.org/mp3info/

License

MP3 VBR Length is licensed under the GNU General Public License, version 2.

About

Calculate the length of MP3 files stored with a variable bitrate.

License:GNU General Public License v2.0


Languages

Language:Java 100.0%