taglib-ts
    Preparing search index...

    ID3v2 tag implementation.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get album(): string

      Gets the album name from the TALB frame.

      Returns string

    • set album(value: string): void

      Sets the album name in the TALB frame.

      Parameters

      • value: string

        The album string; pass an empty string to remove the frame.

      Returns void

    • get artist(): string

      Gets the lead artist/performer from the TPE1 frame.

      Returns string

    • set artist(value: string): void

      Sets the lead artist/performer in the TPE1 frame.

      Parameters

      • value: string

        The artist string; pass an empty string to remove the frame.

      Returns void

    • get comment(): string

      Gets the comment text from the first available COMM frame.

      Returns string

    • set comment(value: string): void

      Sets the comment in a COMM frame, creating one if none exists.

      Parameters

      • value: string

        The comment string; pass an empty string to remove all COMM frames.

      Returns void

    • get genre(): string

      Gets the genre, resolving any ID3v1 numeric references in the TCON frame.

      Returns string

    • set genre(value: string): void

      Sets the genre in the TCON frame.

      Parameters

      • value: string

        The genre string; pass an empty string to remove the frame.

      Returns void

    • get isEmpty(): boolean

      An ID3v2 tag is empty only when it contains no frames at all. This ensures tags that contain only non-text frames (e.g. APIC pictures) are not incorrectly stripped during save.

      Returns boolean

    • get title(): string

      Gets the track title from the TIT2 frame.

      Returns string

    • set title(value: string): void

      Sets the track title in the TIT2 frame.

      Parameters

      • value: string

        The title string; pass an empty string to remove the frame.

      Returns void

    • get track(): number

      Gets the track number from the TRCK frame; supports "N/Total" format.

      Returns number

    • set track(value: number): void

      Sets the track number in the TRCK frame.

      Parameters

      • value: number

        The track number; pass 0 to remove the frame.

      Returns void

    • get year(): number

      Gets the recording year from the TDRC (or legacy TYER) frame as an integer.

      Returns number

    • set year(value: number): void

      Sets the recording year in the TDRC frame.

      Parameters

      • value: number

        The year as an integer; pass 0 to remove the frame.

      Returns void

    Methods

    • Returns the complex properties for the given key. For "PICTURE", returns one map per APIC frame with data, mimeType, description, and pictureType entries.

      Parameters

      • key: string

        The complex-property key (case-insensitive).

      Returns VariantMap[]

      An array of variant maps representing the complex property values.

    • Returns the list of complex-property keys supported by this tag. Currently only "PICTURE" is supported.

      Returns string[]

      An array of complex-property key strings.

    • Returns a map of frame ID to frame list, grouping all frames by their four-character ID. This mirrors the C++ frameListMap() method.

      Returns Map<string, Id3v2Frame[]>

      A Map from frame ID string to the array of frames with that ID.

    • Removes all frames that match the given frame ID.

      Parameters

      • frameId: string | ByteVector

        A four-character frame ID string or ByteVector.

      Returns void

    • Remove properties that are not supported by this tag format. The default implementation is a no-op; subclasses may override.

      Parameters

      • _properties: string[]

        Keys of the properties to remove.

      Returns void

    • Render the complete ID3v2 tag (header + all frames + padding + optional footer) to a ByteVector.

      Padding strategy matches C++ TagLib:

      • Minimum padding is always 1024 bytes.
      • When an existing tag is being re-written and its frames still fit within the original allocated space, the original padding is preserved — but capped at max(1024, fileSize / 100) to avoid unbounded growth. Since we don't have file-size context here the cap is fixed at 1024.
      • When the new frames exceed the original allocated space (or when there is no original tag), exactly 1024 bytes of padding are appended.

      Parameters

      • Optionalversion: number

        The ID3v2 major version to render as; defaults to the tag's current version.

      • fileSize: number = 0

        Optional file size used for the 1% padding threshold (default: 0).

      Returns ByteVector

      The serialised tag bytes.

    • Replaces complex properties for the given key. For "PICTURE", all existing APIC frames are removed and replaced with frames built from the provided variant maps.

      Parameters

      • key: string

        The complex-property key (case-insensitive).

      • value: VariantMap[]

        An array of variant maps, each describing one property value.

      Returns boolean

      true if the key was handled; false otherwise.

    • Copy tag fields from source to target. When overwrite is false, only empty fields in the target are filled in.

      Parameters

      • source: Tag

        The tag to copy values from.

      • target: Tag

        The tag to copy values into.

      • overwrite: boolean

        When true, all fields in target are overwritten; when false, only unset fields are populated.

      Returns void

    • Join an array of tag values with " / ".

      Parameters

      • values: string[]

        The string values to join.

      Returns string

      A single string with values separated by " / ".