I'm not good at java. I'm doing a project that updates the metadata of music files using the library, mp3agic. I don't find the lyrics part in the library. Can someone who is good with ID3 tags, help me access the lyrics?
Asked
Active
Viewed 347 times
1
-
That's a little bit too broad for SO. Show what you have tried so far. – Beryllium Apr 06 '14 at 07:35
-
like i said, i'm not good at java. I'm just running the java program from visual basic (as a batch file) The program has methods like getArtist(),setArtist() etc. Adding lyrics will complete my project. – Ravi Theja Apr 06 '14 at 10:08
1 Answers
1
I know this might be too late and OP might have figured it out already but if someone is still stucked with this, please have a look here
and give the below a try
Edit AbstractID3v2Tag with following changes;
public static final String ID_TEXT_LYRICS = "USLT";
private ID3v2CommentFrameData extractLyricsFrameData(String id) {
ID3v2FrameSet frameSet = frameSets.get(id);
if (frameSet != null) {
Iterator<ID3v2Frame> iterator = frameSet.getFrames().iterator();
while (iterator.hasNext()) {
ID3v2Frame frame = (ID3v2Frame) iterator.next();
ID3v2CommentFrameData frameData;
try {
frameData = new ID3v2CommentFrameData(useFrameUnsynchronisation(), frame.getData());
return frameData;
} catch (InvalidDataException e) {
// Do nothing
}
}
}
return null;
}
public String getLyrics() {
ID3v2CommentFrameData frameData;
if (obseleteFormat) return null;
else frameData = extractLyricsFrameData(ID_TEXT_LYRICS);
if (frameData != null)
return frameData.getComment().toString();
return null;
}
public void setLyrics(String lyrics) {
if (lyrics != null && lyrics.length() > 0) {
invalidateDataLength();
ID3v2CommentFrameData frameData = new ID3v2CommentFrameData(useFrameUnsynchronisation(), "eng", null, new EncodedText(lyrics));
addFrame(createFrame(ID_TEXT_LYRICS, frameData.toBytes()), true);
}
}
Afterwards you can simply call id3v2Tag.setLyrics() and id3v2tag.getLyrics(), this seems to be working fine. Make sure to ascii encode your lyrics body when using setLyrics().

Community
- 1
- 1

Kanishk Gandharv
- 184
- 2
- 5