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 retag() throws IOException, NotSupportedException { updateId3Tags(); updateCustomTag(); mp3file.save(mp3file.getFilename() + RETAG_EXTENSION); renameFiles(); }
Mp3File mp3file = new Mp3File("example.mp3"); ID3v2 id3v2Tag; if (mp3file.hasId3v2Tag()) { id3v2Tag = mp3file.getId3v2Tag(); } else { id3v2Tag = new ID3v24Tag(); mp3file.setId3v2Tag(id3v2Tag); } id3v2Tag.clearAlbumImage(); mp3file.save("example.mp3");
Mp3File mp3file = new Mp3File("SomeMp3File.mp3"); ID3v1 id3v1Tag; if (mp3file.hasId3v1Tag()) { id3v1Tag = mp3file.getId3v1Tag(); } else { // mp3 does not have an ID3v1 tag, let's create one.. id3v1Tag = new ID3v1Tag(); mp3file.setId3v1Tag(id3v1Tag); } id3v1Tag.setTrack("5"); id3v1Tag.setArtist("An Artist"); id3v1Tag.setTitle("The Title"); id3v1Tag.setAlbum("The Album"); id3v1Tag.setYear("2001"); id3v1Tag.setGenre(12); id3v1Tag.setComment("Some comment"); mp3file.save("MyMp3File.mp3");