Lyrics3 Tag is a chunk of data which begins with “LYRICSBEGIN”, ends with “LYRICSEND” and has the lyrics between these keywords. This data block is then saved in the audio file between the audio and the ID3 tag. If no ID3 tag is present one must be attached.
Note
For more information, please visit: http://id3.org/Lyrics3
Reading a Lyrics tag
The GroupDocs.Metadata API allows reading the Lyrics3 tag in an MP3 file.
try(Metadatametadata=newMetadata(Constants.MP3WithLyrics)){MP3RootPackageroot=metadata.getRootPackageGeneric();if(root.getLyrics3V2()!=null){System.out.println(root.getLyrics3V2().getLyrics());System.out.println(root.getLyrics3V2().getAlbum());System.out.println(root.getLyrics3V2().getArtist());System.out.println(root.getLyrics3V2().getTrack());// ...// Alternatively, you can loop through a full list of tag fieldsfor(LyricsFieldfield:root.getLyrics3V2().toList()){System.out.println(String.format("%s = %s",field.getID(),field.getData()));}}}
Updating a Lyrics tag
The GroupDocs.Metadata API supports updating the Lyrics tag in an MP3 audio file.
The following are the steps to update the Lyrics tag in an MP3 file.
try(Metadatametadata=newMetadata(Constants.MP3WithLyrics)){MP3RootPackageroot=metadata.getRootPackageGeneric();if(root.getLyrics3V2()==null){root.setLyrics3V2(newLyricsTag());}root.getLyrics3V2().setLyrics("[00:01]Test lyrics");root.getLyrics3V2().setArtist("test artist");root.getLyrics3V2().setAlbum("test album");root.getLyrics3V2().setTrack("test track");// You can add a fully custom field to the tagroot.getLyrics3V2().set(newLyricsField("ABC","custom value"));// ...metadata.save(Constants.OutputMp3);}
Removing a Lyrics tag
To remove the Lyrics tag from an MP3 audio just pass null to the MP3RootPackage.setLyrics3V2 method. The code sample below shows how to remove the Lyrics tag from an MP3 file.