Hey,
I wonder how I can read out the duration of an mp3 song. If I'm right it's not an ID3 Tag so I guess I have to calculate it somehow ? For the rest of the ID3 Tags I'm using this libary: http://javamusictag.sourceforge.net/index.html
Cheers
Hey,
I wonder how I can read out the duration of an mp3 song. If I'm right it's not an ID3 Tag so I guess I have to calculate it somehow ? For the rest of the ID3 Tags I'm using this libary: http://javamusictag.sourceforge.net/index.html
Cheers
Use some MP3 library. The MP3 format is not that easy that there is some simple way to read out the length of a song.
You could try using MP3SPI which is based on JLayer. The following code will then allow you to get the song duration:
File file = new File("filename.mp3");
AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(file);
Map properties = baseFileFormat.properties();
Long duration = (Long) properties.get("duration");
You can also use MP3SPI to get at the ID3 tags which might save you an extra dependency.