private void initId3v1Tag(SeekableByteChannel seekableByteChannel) throws IOException { ByteBuffer byteBuffer = ByteBuffer.allocate(ID3v1Tag.TAG_LENGTH); seekableByteChannel.position(getLength() - ID3v1Tag.TAG_LENGTH); byteBuffer.clear(); int bytesRead = seekableByteChannel.read(byteBuffer); if (bytesRead < ID3v1Tag.TAG_LENGTH) throw new IOException("Not enough bytes read"); try { id3v1Tag = new ID3v1Tag(byteBuffer.array()); } catch (NoSuchTagException e) { id3v1Tag = null; } }
private void initId3v1Tag(SeekableByteChannel seekableByteChannel) throws IOException { ByteBuffer byteBuffer = ByteBuffer.allocate(ID3v1Tag.TAG_LENGTH); seekableByteChannel.position(getLength() - ID3v1Tag.TAG_LENGTH); byteBuffer.clear(); int bytesRead = seekableByteChannel.read(byteBuffer); if (bytesRead < ID3v1Tag.TAG_LENGTH) throw new IOException("Not enough bytes read"); try { id3v1Tag = new ID3v1Tag(byteBuffer.array()); } catch (NoSuchTagException e) { id3v1Tag = null; } }
id3v1Tag = mp3file.getId3v1Tag(); } else { id3v1Tag = new ID3v1Tag(); mp3file.setId3v1Tag(id3v1Tag);
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");
private void updateId3Tags() { ID3Wrapper oldId3Wrapper = new ID3Wrapper(mp3file.getId3v1Tag(), mp3file.getId3v2Tag()); ID3Wrapper newId3Wrapper = new ID3Wrapper(new ID3v1Tag(), new ID3v23Tag()); preProcess(oldId3Wrapper); newId3Wrapper.setTrack(cleanTrack(oldId3Wrapper.getTrack()));