ID3V2Tag

Inheritance: java.lang.Object, com.groupdocs.metadata.core.MetadataPackage, com.groupdocs.metadata.core.CustomPackage, com.groupdocs.metadata.core.ID3Tag

public final class ID3V2Tag extends ID3Tag

Represents an ID3v2 tag. Please find more information at https://en.wikipedia.org/wiki/ID3#ID3v2 .

Learn more

This example shows how to read the ID3v2 tag in an MP3 file.

try (Metadata metadata = new Metadata(Constants.MP3WithID3V2)) { MP3RootPackage root = metadata.getRootPackageGeneric(); if (root.getID3V2() != null) { System.out.println(root.getID3V2().getAlbum()); System.out.println(root.getID3V2().getArtist()); System.out.println(root.getID3V2().getBand()); System.out.println(root.getID3V2().getTitle()); System.out.println(root.getID3V2().getComposers()); System.out.println(root.getID3V2().getCopyright()); System.out.println(root.getID3V2().getPublisher()); System.out.println(root.getID3V2().getOriginalAlbum()); System.out.println(root.getID3V2().getMusicalKey()); if (root.getID3V2().getAttachedPictures() != null) { for (ID3V2AttachedPictureFrame attachedPicture : root.getID3V2().getAttachedPictures()) { System.out.println(attachedPicture.getAttachedPictureType()); System.out.println(attachedPicture.getMimeType()); System.out.println(attachedPicture.getDescription()); // … } } // … } }

Constructors

Constructor Description
ID3V2Tag() Initializes a new instance of the ID3V2Tag class.

Methods

Method Description
getVersion() Gets the ID3 version.
getTagSize() Gets the size of the tag.
getAlbum() Gets the Album/Movie/Show title.
setAlbum(String value) Sets the Album/Movie/Show title.
getArtist() Gets the Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group.
setArtist(String value) Sets the Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group.
getBand() Gets the Band/Orchestra/Accompaniment.
setBand(String value) Sets the Band/Orchestra/Accompaniment.
getBitsPerMinute() Gets the number of beats per minute in the main part of the audio.
setBitsPerMinute(String value) Sets the number of beats per minute in the main part of the audio.
getComposers() Gets the composers.
setComposers(String value) Sets the composers.
getContentType() Gets the content type.
setContentType(String value) Sets the content type.
getCopyright() Gets the copyright message.
setCopyright(String value) Sets the copyright message.
getDate() Gets a numeric string in the DDMM format containing the date for the recording.
setDate(String value) Sets a numeric string in the DDMM format containing the date for the recording.
getEncodedBy() Gets the name of the person or organization that encoded the audio file.
setEncodedBy(String value) Sets the name of the person or organization that encoded the audio file.
getPublisher() Gets the name of the label or publisher.
setPublisher(String value) Sets the name of the label or publisher.
getTime() Gets a numeric string in the HHMM format containing the time for the recording.
setTime(String value) Sets a numeric string in the HHMM format containing the time for the recording.
getTitle() Gets the Title/Song name/Content description.
setTitle(String value) Sets the Title/Song name/Content description.
getSubtitle() Gets the Subtitle/Description refinement.
setSubtitle(String value) Sets the Subtitle/Description refinement.
getMusicalKey() Gets the musical key in which the sound starts.
setMusicalKey(String value) Sets the musical key in which the sound starts.
getLengthInMilliseconds() Gets the length of the audio file in milliseconds, represented as a numeric string.
setLengthInMilliseconds(String value) Sets the length of the audio file in milliseconds, represented as a numeric string.
getOriginalAlbum() Gets the original album/movie/show title.
setOriginalAlbum(String value) Sets the original album/movie/show title.
getTrackNumber() Gets a numeric string containing the order number of the audio-file on its original recording.
setTrackNumber(String value) Sets a numeric string containing the order number of the audio-file on its original recording.
getSizeInBytes() Gets the size of the audio file in bytes, excluding the ID3v2 tag, represented as a numeric string.
setSizeInBytes(String value) Sets the size of the audio file in bytes, excluding the ID3v2 tag, represented as a numeric string.
getIsrc() Gets the International Standard Recording Code (ISRC) (12 characters).
setIsrc(String value) Sets the International Standard Recording Code (ISRC) (12 characters).
getSoftwareHardware() Gets the used audio encoder and its settings when the file was encoded.
setSoftwareHardware(String value) Sets the used audio encoder and its settings when the file was encoded.
getYear() Gets a numeric string with a year of the recording.
setYear(String value) Sets a numeric string with a year of the recording.
getComments() Gets the user comments.
setComments(ID3V2CommentFrame[] value) Sets the user comments.
getAttachedPictures() Gets the attached pictures directly related to the audio file.
setAttachedPictures(ID3V2AttachedPictureFrame[] value) Sets the attached pictures directly related to the audio file.
getTrackPlayCounter() Gets the number of times the file has been played.
toList() Creates a list from the package.
removeAttachedPictures() Removes all attached pictures stored in APIC frames.
get(String frameId) Gets an array of frames with the specified id.
set(ID3V2TagFrame frame) Removes all frames having the same id as the specified one and adds the new frame to the tag.
clear(String frameId) Removes all frames with the specified id.
add(ID3V2TagFrame frame) Adds a frame to the tag.
remove(ID3V2TagFrame frame) Removes the specified frame from the tag.

ID3V2Tag()

public ID3V2Tag()

Initializes a new instance of the ID3V2Tag class.

getVersion()

public String getVersion()

Gets the ID3 version.

Returns: java.lang.String - The ID3 version.

getTagSize()

public final int getTagSize()

Gets the size of the tag.

Returns: int - The size of the tag.

getAlbum()

public final String getAlbum()

Gets the Album/Movie/Show title. This value is represented by the TALB frame.

Returns: java.lang.String - The Album/Movie/Show title.

setAlbum(String value)

public final void setAlbum(String value)

Sets the Album/Movie/Show title. This value is represented by the TALB frame.

Parameters:

Parameter Type Description
value java.lang.String The Album/Movie/Show title.

getArtist()

public final String getArtist()

Gets the Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group. This value is represented by the TPE1 frame.

Returns: java.lang.String - The Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group.

setArtist(String value)

public final void setArtist(String value)

Sets the Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group. This value is represented by the TPE1 frame.

Parameters:

Parameter Type Description
value java.lang.String The Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group.

getBand()

public final String getBand()

Gets the Band/Orchestra/Accompaniment. This value is represented by the TPE2 frame.

Returns: java.lang.String - The Band/Orchestra/Accompaniment.

setBand(String value)

public final void setBand(String value)

Sets the Band/Orchestra/Accompaniment. This value is represented by the TPE2 frame.

Parameters:

Parameter Type Description
value java.lang.String The Band/Orchestra/Accompaniment.

getBitsPerMinute()

public final String getBitsPerMinute()

Gets the number of beats per minute in the main part of the audio. This value is represented by the TBPM frame.

Returns: java.lang.String - The number of beats per minute in the main part of the audio.

setBitsPerMinute(String value)

public final void setBitsPerMinute(String value)

Sets the number of beats per minute in the main part of the audio. This value is represented by the TBPM frame.

Parameters:

Parameter Type Description
value java.lang.String The number of beats per minute in the main part of the audio.

getComposers()

public final String getComposers()

Gets the composers. The names are separated with the “/” character. This value is represented by the TCOM frame.

Returns: java.lang.String - The composers. The names are separated with the “/” character.

setComposers(String value)

public final void setComposers(String value)

Sets the composers. The names are separated with the “/” character. This value is represented by the TCOM frame.

Parameters:

Parameter Type Description
value java.lang.String The composers. The names are separated with the “/” character.

getContentType()

public final String getContentType()

Gets the content type. This value is represented by the TCON frame.

Returns: java.lang.String - The content type.

setContentType(String value)

public final void setContentType(String value)

Sets the content type. This value is represented by the TCON frame.

Parameters:

Parameter Type Description
value java.lang.String The content type.

getCopyright()

public final String getCopyright()

Gets the copyright message. This value is represented by the TCOP frame.

Returns: java.lang.String - The copyright message.


Every time this field is displayed the field must be preceded with “Copyright ?? “.

setCopyright(String value)

public final void setCopyright(String value)

Sets the copyright message. This value is represented by the TCOP frame.

Parameters:

Parameter Type Description
value java.lang.String The copyright message.

Every time this field is displayed the field must be preceded with “Copyright ?? “. |

getDate()

public final String getDate()

Gets a numeric string in the DDMM format containing the date for the recording. This field is always four characters long. This value is represented by the TDAT frame.

Returns: java.lang.String - A numeric string in the DDMM format containing the date for the recording.

setDate(String value)

public final void setDate(String value)

Sets a numeric string in the DDMM format containing the date for the recording. This field is always four characters long. This value is represented by the TDAT frame.

Parameters:

Parameter Type Description
value java.lang.String A numeric string in the DDMM format containing the date for the recording.

getEncodedBy()

public final String getEncodedBy()

Gets the name of the person or organization that encoded the audio file. This value is represented by the TENC frame.

Returns: java.lang.String - The name of the person or organization that encoded the audio file.

setEncodedBy(String value)

public final void setEncodedBy(String value)

Sets the name of the person or organization that encoded the audio file. This value is represented by the TENC frame.

Parameters:

Parameter Type Description
value java.lang.String The name of the person or organization that encoded the audio file.

getPublisher()

public final String getPublisher()

Gets the name of the label or publisher. This value is represented by the TPUB frame.

Returns: java.lang.String - The name of the label or publisher.

setPublisher(String value)

public final void setPublisher(String value)

Sets the name of the label or publisher. This value is represented by the TPUB frame.

Parameters:

Parameter Type Description
value java.lang.String The name of the label or publisher.

getTime()

public final String getTime()

Gets a numeric string in the HHMM format containing the time for the recording. This field is always four characters long. This value is represented by the TIME frame.

Returns: java.lang.String - A numeric string in the HHMM format containing the time for the recording.

setTime(String value)

public final void setTime(String value)

Sets a numeric string in the HHMM format containing the time for the recording. This field is always four characters long. This value is represented by the TIME frame.

Parameters:

Parameter Type Description
value java.lang.String A numeric string in the HHMM format containing the time for the recording.

getTitle()

public final String getTitle()

Gets the Title/Song name/Content description. This value is represented by the TIT2 frame.

Returns: java.lang.String - The Title/Song name/Content description.

setTitle(String value)

public final void setTitle(String value)

Sets the Title/Song name/Content description. This value is represented by the TIT2 frame.

Parameters:

Parameter Type Description
value java.lang.String The Title/Song name/Content description.

getSubtitle()

public final String getSubtitle()

Gets the Subtitle/Description refinement. This value is represented by the TIT3 frame.

Returns: java.lang.String - The Subtitle/Description refinement.

setSubtitle(String value)

public final void setSubtitle(String value)

Sets the Subtitle/Description refinement. This value is represented by the TIT3 frame.

Parameters:

Parameter Type Description
value java.lang.String The Subtitle/Description refinement.

getMusicalKey()

public final String getMusicalKey()

Gets the musical key in which the sound starts. This value is represented by the TKEY frame.

Returns: java.lang.String - The musical key in which the sound starts.

setMusicalKey(String value)

public final void setMusicalKey(String value)

Sets the musical key in which the sound starts. This value is represented by the TKEY frame.

Parameters:

Parameter Type Description
value java.lang.String The musical key in which the sound starts.

getLengthInMilliseconds()

public final String getLengthInMilliseconds()

Gets the length of the audio file in milliseconds, represented as a numeric string. This value is represented by the TLEN frame.

Returns: java.lang.String - The length of the audio file in milliseconds, represented as a numeric string.

setLengthInMilliseconds(String value)

public final void setLengthInMilliseconds(String value)

Sets the length of the audio file in milliseconds, represented as a numeric string. This value is represented by the TLEN frame.

Parameters:

Parameter Type Description
value java.lang.String The length of the audio file in milliseconds, represented as a numeric string.

getOriginalAlbum()

public final String getOriginalAlbum()

Gets the original album/movie/show title. This value is represented by the TOAL frame.

Returns: java.lang.String - The original album/movie/show title.

setOriginalAlbum(String value)

public final void setOriginalAlbum(String value)

Sets the original album/movie/show title. This value is represented by the TOAL frame.

Parameters:

Parameter Type Description
value java.lang.String The original album/movie/show title.

getTrackNumber()

public final String getTrackNumber()

Gets a numeric string containing the order number of the audio-file on its original recording. This value is represented by the TRCK frame.

Returns: java.lang.String - A numeric string containing the order number of the audio-file on its original recording

setTrackNumber(String value)

public final void setTrackNumber(String value)

Sets a numeric string containing the order number of the audio-file on its original recording. This value is represented by the TRCK frame.

Parameters:

Parameter Type Description
value java.lang.String A numeric string containing the order number of the audio-file on its original recording

getSizeInBytes()

public final String getSizeInBytes()

Gets the size of the audio file in bytes, excluding the ID3v2 tag, represented as a numeric string. This value is represented by the TSIZ frame.

Returns: java.lang.String - The size of the audio file in bytes, excluding the ID3v2 tag, represented as a numeric string.

setSizeInBytes(String value)

public final void setSizeInBytes(String value)

Sets the size of the audio file in bytes, excluding the ID3v2 tag, represented as a numeric string. This value is represented by the TSIZ frame.

Parameters:

Parameter Type Description
value java.lang.String The size of the audio file in bytes, excluding the ID3v2 tag, represented as a numeric string.

getIsrc()

public final String getIsrc()

Gets the International Standard Recording Code (ISRC) (12 characters). This value is represented by the TSRC frame.

Returns: java.lang.String - The International Standard Recording Code (ISRC) (12 characters).

setIsrc(String value)

public final void setIsrc(String value)

Sets the International Standard Recording Code (ISRC) (12 characters). This value is represented by the TSRC frame.

Parameters:

Parameter Type Description
value java.lang.String The International Standard Recording Code (ISRC) (12 characters).

getSoftwareHardware()

public final String getSoftwareHardware()

Gets the used audio encoder and its settings when the file was encoded. This value is represented by the TSSE frame.

Returns: java.lang.String - The used audio encoder and its settings when the file was encoded.

setSoftwareHardware(String value)

public final void setSoftwareHardware(String value)

Sets the used audio encoder and its settings when the file was encoded. This value is represented by the TSSE frame.

Parameters:

Parameter Type Description
value java.lang.String The used audio encoder and its settings when the file was encoded.

getYear()

public final String getYear()

Gets a numeric string with a year of the recording. This frames is always four characters long (until the year 10000). This value is represented by the TYER frame.

Returns: java.lang.String - A numeric string with a year of the recording. This frames is always four characters long (until the year 10000).

setYear(String value)

public final void setYear(String value)

Sets a numeric string with a year of the recording. This frames is always four characters long (until the year 10000). This value is represented by the TYER frame.

Parameters:

Parameter Type Description
value java.lang.String A numeric string with a year of the recording. This frames is always four characters long (until the year 10000).

getComments()

public final ID3V2CommentFrame[] getComments()

Gets the user comments. This value is represented by the COMM frame. The frame is intended for any kind of full text information that does not fit in any other frame.

Returns: com.groupdocs.metadata.core.ID3V2CommentFrame[] - The user comments.

setComments(ID3V2CommentFrame[] value)

public final void setComments(ID3V2CommentFrame[] value)

Sets the user comments. This value is represented by the COMM frame. The frame is intended for any kind of full text information that does not fit in any other frame.

Parameters:

Parameter Type Description
value ID3V2CommentFrame[] The user comments.

getAttachedPictures()

public final ID3V2AttachedPictureFrame[] getAttachedPictures()

Gets the attached pictures directly related to the audio file. This value is represented by the APIC frame.

Returns: com.groupdocs.metadata.core.ID3V2AttachedPictureFrame[] - The attached pictures directly related to the audio file.

setAttachedPictures(ID3V2AttachedPictureFrame[] value)

public final void setAttachedPictures(ID3V2AttachedPictureFrame[] value)

Sets the attached pictures directly related to the audio file. This value is represented by the APIC frame.

Parameters:

Parameter Type Description
value ID3V2AttachedPictureFrame[] The attached pictures directly related to the audio file.

getTrackPlayCounter()

public final Long getTrackPlayCounter()

Gets the number of times the file has been played. This value is represented by the PCNT frame.

Returns: java.lang.Long - The number of times a file has been played.

toList()

public final IReadOnlyList<ID3V2TagFrame> toList()

Creates a list from the package.

Returns: IReadOnlyList - A list of all frames contained in the ID3v2 tag.

removeAttachedPictures()

public final void removeAttachedPictures()

Removes all attached pictures stored in APIC frames.

get(String frameId)

public final ID3V2TagFrame[] get(String frameId)

Gets an array of frames with the specified id.

Parameters:

Parameter Type Description
frameId java.lang.String The id of the frames to get.

Returns: com.groupdocs.metadata.core.ID3V2TagFrame[] - An array of frames with the specified id.

set(ID3V2TagFrame frame)

public final void set(ID3V2TagFrame frame)

Removes all frames having the same id as the specified one and adds the new frame to the tag.

Parameters:

Parameter Type Description
frame ID3V2TagFrame The frame to replace all frames of its kind with.

clear(String frameId)

public final void clear(String frameId)

Removes all frames with the specified id.

Parameters:

Parameter Type Description
frameId java.lang.String The id of the frames to remove.

add(ID3V2TagFrame frame)

public final void add(ID3V2TagFrame frame)

Adds a frame to the tag.

Parameters:

Parameter Type Description
frame ID3V2TagFrame The frame to be added to the tag.

remove(ID3V2TagFrame frame)

public final void remove(ID3V2TagFrame frame)

Removes the specified frame from the tag.

Parameters:

Parameter Type Description
frame ID3V2TagFrame The frame to be removed from the tag.