0

I have exhausted all the possible code that was listed, none of the code seems to work for me to change album art of a song. And jaudiotagger documentation is not helpful as well.

Tag tag = audioFile.getTag();
Artwork artwork = 
ArtworkFactory.createLinkedArtworkFromURL(imgDecodableString);
tag.setField(artwork)
AndroidDev
  • 1,485
  • 2
  • 18
  • 33

1 Answers1

0

Can you try this part of code ? We are using this from many years ;)

Don't forget first to delete previous tags if already exist ...

ID3v24Tag id3v24Tag = new ID3v24Tag();
Artwork artworkCover = Artwork.createArtworkFromFile(artworkFile); // artworkFile is an jpg file
id3v24Tag.addField(artworkCover);

To delete previous you can do something like:

MP3File mp3File = (MP3File) AudioFileIO.read(soundFile);

if (mp3File.hasID3v1Tag()) {
    mp3File.delete(mp3File.getID3v1Tag())
    mp3File.setID3v1Tag(null)
}

if (mp3File.hasID3v2Tag()) {
    mp3File.delete(mp3File.getID3v2Tag())
    mp3File.delete(mp3File.getID3v2TagAsv24())
    mp3File.setID3v2Tag(null)
    mp3File.setID3v2TagOnly(null)
}

mp3File.setTag(null)
mp3File.commit()
ogl
  • 1
  • The above code didn't work for me. Are you sure the above code is working for you ? And why do we have to delete previous tags ? We should just be deleting the old album art that was there right. – AndroidDev Sep 17 '19 at 14:32