I want to write lyrics to an mp3 in an Android application.I have found a java library for reading mp3
files and reading/manipulating the ID3 tags (ID3v1 and ID3v2.2 through ID3v2.4), named mp3agic.
I modified mp3agic
to write the lyric tag of the ID3v2 tag, writing the tag: USLT
. Found in Wikipedia
In a sample Android app I modify the artist, album, title, genre, lyrics, and comment of an MP3. All tags are modified correct except for the lyrics. PowerAMP
is used to verify the modified MP3
file and PowerAMP
cannot find the lyrics in the MP3.
If anyone is familiar with this library here is my modified code from AbstractID3v2Tag.java:
//define lyric tag for id3v2
public static final String ID_TEXT_LYRICS = "USLT";
//get the lyrics from the tag
public String getLyrics() {
ID3v2TextFrameData frameData;
if (obseleteFormat) return null;
else frameData = extractTextFrameData(ID_TEXT_LYRICS);
if (frameData != null && frameData.getText() != null)
return frameData.getText().toString();
return null;
}
//set the lyrics in the tag
public void setLyrics(String lyrics) {
if (lyrics != null && lyrics.length() > 0) {
invalidateDataLength();
ID3v2TextFrameData frameData = new ID3v2TextFrameData(useFrameUnsynchronisation(), new EncodedText(lyrics));
addFrame(createFrame(ID_TEXT_LYRICS, frameData.toBytes()), true);
}
}
I set the lyrics on an MP3
with a program in Windows and read the USLT
tag with my app and getLyrics()
returned the string eng
. PowerAMP
did find these lyrics set by the Windows program.
I have searched and found many posts pointing to MP3 ID3 tag modifier library's, that's where I found mp3agic. Which is the only library I could easily modify to incorporate changing of lyrics.
One library I found was MyID3_for_Android which did not have a method to modify lyrics.
I am looking for guidance on this.