public class ID3v24Tag
extends java.lang.Object
This class provides methods for reading and writing an ID3V2.4 tag. It provides direct low level access to the actual ID3v2.4 tag embedded in an .mp3 file.
The tag is where all the information about the .mp3 file is stored. Information such as the song title, the track number, the lyrics of the song, the band who recorded
the song, etc. are stored inside the tag. As shown below, a tag is composed of the four parts: header
, extended header
,
frames
, and either padding or a footer
.
|
It is beyond the scope of this class description to explain the complete details of the ID3v2.4 tag. However, if you need more information about the format of the ID3v2.4 tag, please visit the official ID3v2.4 website.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PADDING_SIZE
amount of padding (in bytes) that will be added when the ID3v2.4 tag runs out of room for frames and needs to be resized.
|
Constructor and Description |
---|
ID3v24Tag()
default constructor.
|
ID3v24Tag(java.io.InputStream inputStream)
constructor.
|
Modifier and Type | Method and Description |
---|---|
ID3v24Frame |
addFrame(FrameType frameType)
add a default constructed ID3v2.4 frame of the specified type to the ID3v2.4 tag.
|
ID3v24Frame |
addFrame(ID3v24Frame frame)
add the specified ID3v2.4 frame to the ID3v2.4 tag.
|
ID3v24TagExtendedHeader |
getExtendedHeader()
get the optional ID3v2.4 tag extended header.
|
ID3v24TagFooter |
getFooter()
gets the ID3v2.4 tag's footer.
|
ID3v24Frame |
getFrame(FrameType frameType)
finds the first ID3v2.4 frame in the ID3v2.4 tag with the specified ID3v2.4 frame id.
|
java.util.List<ID3v24Frame> |
getFrames()
gets the list of ID3v2.4 frames stored in the ID3v2.4 tag.
|
java.util.List<ID3v24Frame> |
getFrames(FrameType frameType)
finds all the ID3v2.4 frames in the ID3v2.4 tag with the specified ID3v2.4 frame id.
|
ID3v24TagHeader |
getHeader()
gets the ID3v2.4 tag's header.
|
java.util.List<ID3v24Frame> |
getInvalidFrames()
gets the list of the invalid frames encountered while reading in the ID3v2.4 tag.
|
byte[] |
getPadding()
gets the amount of padding at the end of the ID3v2.4 tag.
|
int |
getSize()
gets the size (in bytes) of the ID3v2.4 tag in the .mp3 file.
|
ID3TagVersion |
getVersion()
gets the version of the ID3 tag stored in the .mp3 song which holds all of the information about the .mp3 file.
|
boolean |
isDirty()
gets whether the ID3v2.4 tag has been modified since the last time it was saved.
|
ID3v24Frame |
removeFrame(FrameType frameType)
removes the first ID3v2.4 frame with the specified ID3v2.4 frame id from the ID3v2.4 tag.
|
void |
removeFrames()
removes all the ID3v2.4 frames from the ID3v2.4 tag.
|
java.util.List<ID3v24Frame> |
removeFrames(FrameType frameType)
removes all the ID3v2.4 frames with the specified ID3v2.4 frame id from the ID3v2.4 tag.
|
void |
save(java.io.OutputStream outputStream)
save the ID3v2.4 tag to the .mp3 file.
|
void |
save(java.io.RandomAccessFile file)
save the ID3v2.4 tag to the .mp3 file.
|
void |
setBuffer()
if the tag's values have been modified, then resize the raw binary buffer and store the new values there.
|
void |
setExtendedHeader(ID3v24TagExtendedHeader extendedHeader)
sets the optional ID3v2.4 extended header as well as the
tag header 's extendedHeaderPresent flag. |
void |
setFooter(ID3v24TagFooter footer)
sets the ID3v2.4 tag's footer.
|
void |
setFrames(java.util.List<ID3v24Frame> frames)
sets the list of frames and stores them in the ID3v2.4 tag.
|
void |
setHeader(ID3v24TagHeader header)
sets the ID3v2.4 tag's header.
|
void |
setPadding(int size)
sets the amount of padding that should be reserved at the end of the ID3v2.4 tag.
|
java.lang.String |
toString()
gets a string representation of the ID3v2.4 tag.
|
public static int DEFAULT_PADDING_SIZE
public ID3v24Tag()
public ID3v24Tag(java.io.InputStream inputStream) throws java.io.IOException
invalid frames
. See the ID3v24FrameHeader
class for more details on the
Beaglebuddy MP3 library's error handling.inputStream
- input stream mp3 file whose ID3v2.4 tag is to be read. The input stream has already read in the ID3v2.4 tag header id/version bytes and is pointing
to the remainder of the header.java.io.IOException
- if there was an error while loading the ID3v2.4 tag from the .mp3 file.public ID3v24TagHeader getHeader()
setHeader(ID3v24TagHeader)
public void setHeader(ID3v24TagHeader header)
header
- the ID3v2.4 tag's header.getHeader()
public ID3v24TagExtendedHeader getExtendedHeader() throws java.lang.IllegalStateException
tag header's
extendedHeaderPresent flag is set.java.lang.IllegalStateException
- if the extendedHeaderPresent flag is not set.setExtendedHeader(ID3v24TagExtendedHeader)
,
ID3v24TagHeader.isExtendedHeaderPresent()
,
ID3v24TagHeader.setExtendedHeaderPresent(boolean)
public void setExtendedHeader(ID3v24TagExtendedHeader extendedHeader)
tag header
's extendedHeaderPresent flag.extendedHeader
- an optional ID3v24 extended header.getExtendedHeader()
,
ID3v24TagHeader.isExtendedHeaderPresent()
,
ID3v24TagHeader.setExtendedHeaderPresent(boolean)
public ID3v24TagFooter getFooter() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the footerPresent
flag is not set.setFooter(ID3v24TagFooter)
public void setFooter(ID3v24TagFooter footer)
footer
- the ID3v2.4 tag's footer.getFooter()
public ID3v24Frame addFrame(FrameType frameType)
frameType
- type of ID3v2.4 frame to add to the ID3v2.4 tag.public ID3v24Frame addFrame(ID3v24Frame frame)
frame
- ID3v2.4 frame to add to the ID3v2.4 tag.public ID3v24Frame getFrame(FrameType frameType)
frameType
- type of ID3v2.4 frame to search for.public java.util.List<ID3v24Frame> getFrames()
setFrames(List)
public java.util.List<ID3v24Frame> getFrames(FrameType frameType)
frameType
- type of ID3v2.4 frames to retrieve from the ID3v2.4 tag.public ID3v24Frame removeFrame(FrameType frameType)
frameType
- type of type ID3v2.4 frame to remove from the ID3v2.4 tag.public java.util.List<ID3v24Frame> removeFrames(FrameType frameType)
frameType
- type of ID3v2.4 frame to remove from the ID3v2.4 tag.public void removeFrames()
public void setFrames(java.util.List<ID3v24Frame> frames)
frames
- a list of ID3v2.4 frames containing information about the .mp3 song.getFrames()
public java.util.List<ID3v24Frame> getInvalidFrames()
setFrames(List)
public byte[] getPadding()
setPadding(int)
public void setPadding(int size)
size
- the size (in bytes) of the new padding.getPadding()
public int getSize()
public ID3TagVersion getVersion()
public boolean isDirty()
public void setBuffer()
public void save(java.io.OutputStream outputStream) throws java.io.IOException
outputStream
- output stream pointing to the starting location of the ID3v2.4 tag within the .mp3 file.java.io.IOException
- if there was an error writing the ID3v2.4 tag to the .mp3 file.public void save(java.io.RandomAccessFile file) throws java.io.IOException
file
- random access file pointing to the starting location of the ID3v2.4 tag within the .mp3 file.java.io.IOException
- if there was an error writing the ID3v2.4 tag to the .mp3 file.public java.lang.String toString()
toString
in class java.lang.Object