Class: Id3v2Frame

November 25, 2024 · View on GitHub

node-taglib-sharp / Exports / Id3v2Frame

Class: Id3v2Frame

Abstract class that represents an ID3v2 frame. Frames are the unit for storing information in an ID3v2 tag. There are various types of frames that store differently structured information.

Hierarchy

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

Protected new Id3v2Frame(header)

Constructs and initializes a new instance with a frame header.

Parameters

NameTypeDescription
headerId3v2FrameHeaderHeader for the frame.

Accessors

encryptionId

get encryptionId(): number

Gets the encryption ID applied to the current instance.

Returns

number

Value containing the encryption identifier for the current instance or undefined if not set.

set encryptionId(value): void

Sets the encryption ID applied to the current instance.

Parameters

NameTypeDescription
valuenumberValue containing the encryption identifier for the current instance. Must be an 8-bit unsigned integer. Setting to undefined will remove the encryption header and ID

Returns

void


flags

get flags(): Id3v2FrameFlags

Gets the frame flags applied to the current instance.

Returns

Id3v2FrameFlags

set flags(value): void

Sets the frame flags applied to the current instance. If the value includes either Encryption or Compression, render will throw.

Parameters

NameType
valueId3v2FrameFlags

Returns

void


frameClassType

Abstract get frameClassType(): Id3v2FrameClassType

Gets a flag indicating which type of frame the current instance is.

Returns

Id3v2FrameClassType


frameId

get frameId(): Id3v2FrameIdentifier

Gets the frame ID for the current instance.

Returns

Id3v2FrameIdentifier

Object representing of the identifier of the frame


groupId

get groupId(): number

Gets the grouping ID applied to the current instance.

Returns

number

Value containing the grouping identifier for the current instance, or undefined if not set.

set groupId(value): void

Sets the grouping ID applied to the current instance.

Parameters

NameTypeDescription
valuenumberGrouping identifier for the current instance. Must be an 8-bit unsigned integer. Setting to undefined will remove the grouping identity header and ID

Returns

void


Protected get header(): Id3v2FrameHeader

Gets the header for the frame. For new frames this should not exist.

Returns

Id3v2FrameHeader

Protected set header(value): void

Sets the header for the frame.

Parameters

NameTypeDescription
valueId3v2FrameHeaderHeader for the frame

Returns

void


size

get size(): number

Gets the size of the current instance as it was last stored on disk. NOTE: This value is not used outside of reading a frame from disk, so newly created frames should not have this value set.

Returns

number

Methods

clone

Abstract clone(): Id3v2Frame

Creates a deep copy of the current instance. This method is implemented by rendering the current instance as an ID3v2.4 frame and using the frame factory to create a new frame. As such, this method should be overridden by child classes.

Returns

Id3v2Frame


fieldData

Protected fieldData(frameData, offset, version, dataIncludesHeader): ByteVector

Extracts the field data from the raw portion of an ID3v2 frame. This method is necessary for extracting extra data prepended to the frame such the as grouping ID.

Parameters

NameTypeDescription
frameDataByteVectorRaw frame data
offsetnumberIndex at which the data is contained
versionnumberVersion of the ID3v2 tag the data was originally encoded with
dataIncludesHeaderbooleantrue if frameData includes the header, false otherwise

Returns

ByteVector


parseFields

Protected Abstract parseFields(data, version): void

Populates the values in this frame by parsing its field data in a specified version.

Parameters

NameTypeDescription
dataByteVectorExtracted field data
versionnumberID3v2 version the field data is encoded in

Returns

void


render

render(version): ByteVector

Renders the current instance, encoded in a specified ID3v2 version.

Parameters

NameTypeDescription
versionnumberVersion of ID3v2 to use when encoding the current instance

Returns

ByteVector


renderFields

Protected Abstract renderFields(version): ByteVector

Renders the values in the current instance into field data for a specified version.

Parameters

NameTypeDescription
versionnumberID3v2 version the field data is to be encoded in.

Returns

ByteVector


setData

Protected setData(data, offset, readHeader, version): void

Populates the current instance by reading the raw frame from disk, optionally reading the header.

Parameters

NameTypeDescription
dataByteVectorRaw ID3v2 frame
offsetnumberOffset in data at which the frame begins.
readHeaderbooleanWhether or not to read the reader into the current instance.
versionnumberVersion of the ID3v2 tag the data was encoded with

Returns

void


correctEncoding

Static Protected correctEncoding(type, version): StringType

Converts an encoding to be a supported encoding for a specified tag version.

Parameters

NameTypeDescription
typeStringTypeValue containing the original encoding
versionnumberValue containing the ID3v2 version to be encoded.

Returns

StringType

Value containing the correct encoding to use, based on forceDefaultEncoding and what is supported by version