How to change song cover art of a song using jaudiotagger in android?

359 views Asked by At

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)
1

There are 1 answers

1
ogl On

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()