Mp3File mp3file = new Mp3File("SomeMp3File.mp3"); System.out.println("Length of this mp3 in seconds is: " + mp3file.getLengthInSeconds()); if(mp3file.hasId3v2Tag()) { ID3v2 id3v2tag = mp3file.getId3v2Tag(); System.out.println("The artist in the ID3v2 tag is: " + id3v2tag.getArtist()); id3v2tag.setArtist("A new artist"); mp3file.save("ASavedMp3File.mp3"); System.out("Saved mp3 file with new name and artist set to 'A new artist'"); }
private void catalogMp3Fields(StringBuffer cat) { catalogField(cat, FileUtils.extractFilename(mp3file.getFilename())); catalogField(cat, Long.toString(mp3file.getLength())); catalogField(cat, Long.toString(mp3file.getLengthInSeconds())); catalogField(cat, mp3file.getVersion()); catalogField(cat, mp3file.getLayer()); catalogField(cat, Integer.toString(mp3file.getSampleRate())); catalogField(cat, Integer.toString(mp3file.getBitrate())); catalogField(cat, vbrString(mp3file.isVbr())); catalogField(cat, mp3file.getChannelMode()); }
private void showMp3Fields(StringBuffer buffer) { buffer.append("MP3 Data\n"); showField(buffer, "Filename", FileUtils.extractFilename(mp3file.getFilename())); showField(buffer, "Size", Long.toString(mp3file.getLength())); showField(buffer, "Length", formatTime(mp3file.getLengthInSeconds())); showField(buffer, "Version", mp3file.getVersion()); showField(buffer, "Layer", mp3file.getLayer()); showField(buffer, "Sample rate", Integer.toString(mp3file.getSampleRate()), "Hz"); showField(buffer, "Bitrate", Integer.toString(mp3file.getBitrate()), "kbps (" + vbrString(mp3file.isVbr()) + ")"); showField(buffer, "Channel mode", mp3file.getChannelMode()); }
public static void main(String[] args) throws UnsupportedTagException, InvalidDataException, IOException, NotSupportedException { Mp3File mp3file = new Mp3File("src/test/resources/v1andv23tagswithalbumimage.mp3"); System.out.println("Length of this mp3 is: " + mp3file.getLengthInSeconds() + " seconds"); System.out.println("Bitrate: " + mp3file.getBitrate() + " kbps " + (mp3file.isVbr() ? "(VBR)" : "(CBR)")); System.out.println("Sample rate: " + mp3file.getSampleRate() + " Hz");