public class ID3v24FrameBodyUnsynchronizedLyrics extends ID3v24FrameBody
![]() |
![]() |
An unsynchronized lyrics frame body is associated with an ID3v2.4 USLT
frame
which is used to include the lyrics
to a song or a text transcription of other vocal activities in an .mp3 file. This is similar to the synchronized lyrics/text
frame, but the lyrics
in this, the unsynchronized lyrics frame body, are not synchronized with the audio of the .mp3 file. Just like the lyrics that are printed on a CD booklet, the lyrics
found in this frame are the entire lyrics for song.
The unsynchronized lyrics frame body contains the following fields:
Field | Description | |
---|---|---|
1. | encoding | character set used to encode the description and text fields. |
2. | language | language that the text field is written in. |
3. | description | description of the lyrics/text stored in the text field. |
4. | text | the actual text of the lyrics. |
There may be more than one unsynchronized lyrics frame in an ID3v2.4 tag
, but only one with the same
language and description fields. Thus, you may have the english lyrics, the spanish lyrics, and the german lyrics all in the same tag.
example:
import java.io.IOException;
import java.util.List;
import com.beaglebuddy.id3.enums.Language;
import com.beaglebuddy.id3.enums.v24.Encoding;
import com.beaglebuddy.id3.enums.v24.FrameType;
import com.beaglebuddy.id3.v24.ID3v24Frame;
import com.beaglebuddy.id3.v24.ID3v24Tag;
import com.beaglebuddy.id3.v24.frame_body.ID3v24FrameBodyUnsynchronizedLyrics;
import com.beaglebuddy.mp3.MP3;
public class Lyrics
{
public static void main(String[] args)
{
try
{
// add Bon Jovi's "Livin on a Prayer" lyrics to the .mp3
MP3 mp3 = new MP3("c:\\music\\bon jovi\\livin on a prayer.mp3");
ID3v24Tag iD3v24Tag = mp3.getID3v24Tag();
List<ID3v24Frame> frames = iD3v24Tag.getFrames();
String lyrics = "Tommy used to work on the docks, Union's been on strike, He's down on his luck It's tough, ....";
// if there was any invalid information (ie, frames) in the .mp3 file, then display the errors to the user
if (mp3.hasErrors())
{
mp3.displayErrors(System.out); // display the errors that were found
mp3.save(); // discard the invalid information (frames) and
} // save only the valid frames back to the .mp3 file
// add the unsynchronized lyrics frame to the ID3v2.4 tag
ID3v24Frame frame = new ID3v24Frame(FrameType.UNSYCHRONIZED_LYRICS, new ID3v24FrameBodyUnsynchronizedLyrics(Encoding.UTF_16, Language.ENG, "lyrics", lyrics));
frames.add(frame);
// save the ID3v2.4 tag to the .mp3 file
mp3.save();
System.out.println(mp3);
}
catch (IOException ex)
{
// an error occurred reading/saving the .mp3 file.
// you may try to read it again to see if the error still occurs.
ex.printStackTrace();
}
}
}
buffer, dirty, frameType
nextNullTerminatorIndex, nullTerminatorIndex
Constructor and Description |
---|
ID3v24FrameBodyUnsynchronizedLyrics()
The default constructor is called when creating a new frame.
|
ID3v24FrameBodyUnsynchronizedLyrics(Encoding encoding,
Language language,
java.lang.String description,
java.lang.String text)
This constructor is called when creating a new frame.
|
ID3v24FrameBodyUnsynchronizedLyrics(java.io.InputStream inputStream,
int frameBodySize)
This constructor is called when reading in an existing frame from an .mp3 file.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDescription()
gets the description of the lyrics.
|
Encoding |
getEncoding()
gets the character encoding of the description and the text (lyrics).
|
Language |
getLanguage()
gets the
language the unsynchronized lyrics are written in. |
java.lang.String |
getText()
gets the lyrics to the song.
|
void |
parse()
parses the raw bytes of the frame body and stores the parsed values in the frame's fields.
|
void |
setBuffer()
If the frame body's values have been modified, then resize the raw binary buffer and store the new values there.
|
void |
setDescription(java.lang.String description)
sets the description of the lyrics.
|
void |
setEncoding(Encoding encoding)
sets the character encoding of the description and the text (lyrics).
|
void |
setLanguage(Language language)
sets the
language the unsynchronized lyrics are written in. |
void |
setText(java.lang.String text)
sets the lyrics to the song.
|
java.lang.String |
toString()
gets a string representation of the unsynchronized lyrics frame body and shows the values of all its fields.
|
getFrameType, getNextNullTerminator, getSize, isDirty, save, save
bytesToInt, bytesToShort, bytesToSynchsafeInt, bytesToSynchsafeShort, formateDate, getNextNullTerminator, hex, hex, intToBytes, pad, pricesToString, shortToBytes, stringToBytes, synchsafeIntToBytes
public ID3v24FrameBodyUnsynchronizedLyrics()
public ID3v24FrameBodyUnsynchronizedLyrics(Encoding encoding, Language language, java.lang.String description, java.lang.String text)
encoding
- character set used to encode the description and the lyrics.language
- ISO-639-2 Language
code the lryics are written in.description
- description of the lyrics.text
- lyrics to the song in the specified language.public ID3v24FrameBodyUnsynchronizedLyrics(java.io.InputStream inputStream, int frameBodySize) throws java.io.IOException
inputStream
- input stream pointing to an unsychronized lyrics/text transcription frame body in the .mp3 file.frameBodySize
- size (in bytes) of the frame's body.java.io.IOException
- if there is an error while reading the frame body.public void parse() throws java.lang.IllegalArgumentException
parse
in class ID3v24FrameBody
java.lang.IllegalArgumentException
- if an invalid value is detected while parsing the frame body's raw bytes.public Encoding getEncoding()
setEncoding(Encoding)
public void setEncoding(Encoding encoding)
encoding
- the character set used to encode the description and the text (lyrics). Only ISO 8859-1 and UTF-16 are allowed.getEncoding()
public Language getLanguage()
language
the unsynchronized lyrics are written in.language
the unsynchronized lyrics are written in.setLanguage(Language)
public void setLanguage(Language language)
language
the unsynchronized lyrics are written in.language
- language
the unsynchronized lyrics are written in.getLanguage()
public java.lang.String getDescription()
setDescription(String)
public void setDescription(java.lang.String description)
description
- the description of the lyrics.getDescription()
public java.lang.String getText()
setText(String)
public void setText(java.lang.String text)
text
- the text of the lyrics.getText()
public void setBuffer()
setBuffer
in class ID3v24FrameBody
public java.lang.String toString()
toString
in class java.lang.Object