taglib-ts
    Preparing search index...

    Xiph/Vorbis comment tag implementation.

    Binary format: vendorLength(4 LE) + vendor(UTF-8) + commentCount(4 LE) + for each: stringLength(4 LE) + "KEY=VALUE"(UTF-8)

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get album(): string

      Album title stored in the "ALBUM" field.

      Returns string

    • set album(v: string): void

      Parameters

      • v: string

        New album string; empty string removes the field.

      Returns void

    • get artist(): string

      Lead artist/performer stored in the "ARTIST" field.

      Returns string

    • set artist(v: string): void

      Parameters

      • v: string

        New artist string; empty string removes the field.

      Returns void

    • get comment(): string

      User comment, read from "COMMENT" (preferred, matching C++ TagLib default) or "DESCRIPTION" as a fallback for tags written by older encoders.

      Returns string

      The comment string, or "" if neither field is set.

    • set comment(v: string): void

      Sets the comment. Matches C++ TagLib XiphComment::setComment(): if a "DESCRIPTION" field already exists (loaded from file), update that field; otherwise write to "COMMENT" (the standard Vorbis comment field name).

      Parameters

      • v: string

        New comment string; empty string removes the field.

      Returns void

    • get fieldCount(): number

      Total number of individual field values across all keys.

      Returns number

    • get genre(): string

      Genre stored in the "GENRE" field.

      Returns string

    • set genre(v: string): void

      Parameters

      • v: string

        New genre string; empty string removes the field.

      Returns void

    • get isEmpty(): boolean

      A Xiph comment is empty when all field lists are empty. This matches the C++ TagLib behaviour and ensures tags with only METADATA_BLOCK_PICTURE or other non-standard fields are not stripped.

      Returns boolean

    • get title(): string

      Track title stored in the "TITLE" field.

      Returns string

    • set title(v: string): void

      Parameters

      • v: string

        New title string; empty string removes the field.

      Returns void

    • get track(): number

      Track number, read from "TRACKNUMBER" (preferred) or "TRACKNUM" as a fallback. Returns 0 when not set.

      Returns number

    • set track(v: number): void

      Sets the track number in "TRACKNUMBER" and removes any "TRACKNUM" alias.

      Parameters

      • v: number

        Track number, or 0 to remove the field.

      Returns void

    • get vendorId(): string

      The vendor identification string embedded in the comment header.

      Returns string

    • set vendorId(v: string): void

      Parameters

      • v: string

        New vendor ID string.

      Returns void

    • get year(): number

      Release year, read from "DATE" (preferred) or "YEAR" as a fallback. Returns 0 when not set.

      Returns number

    • set year(v: number): void

      Sets the year in the "DATE" field and removes any "YEAR" alias.

      Parameters

      • v: number

        Four-digit year, or 0 to remove the field.

      Returns void

    Methods

    • Add or replace a field value.

      Parameters

      • key: string

        Field name (case-insensitive, stored uppercase)

      • value: string

        The value to set. Empty string removes the field.

      • replace: boolean = true

        If true (default), replaces all existing values for this key

      Returns void

    • Returns structured complex property data for the given key.

      Parameters

      • key: string

        The complex property key (only "PICTURE" is supported).

      Returns VariantMap[]

      Array of variant maps describing each embedded picture, or [] for unknown keys.

    • Returns the list of complex property keys supported by this tag.

      Returns string[]

      ["PICTURE"] if any embedded pictures are present, otherwise [].

    • Check whether a field with the given key is present.

      Parameters

      • key: string

        Field name (case-insensitive).

      Returns boolean

      true if at least one value exists for key.

    • Returns a shallow copy of the internal field map.

      Returns Map<string, string[]>

      A new Map of uppercased field names to their value arrays.

    • Remove all fields from this comment, leaving an empty tag.

      Returns void

    • Remove all pictures by deleting the METADATA_BLOCK_PICTURE field entirely.

      Returns void

    • Remove all values for the specified field key.

      Parameters

      • key: string

        Field name (case-insensitive).

      Returns void

    • Remove a specific value from the specified field key. Other values for the same key are left intact.

      Parameters

      • key: string

        Field name (case-insensitive).

      • value: string

        The exact value to remove.

      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 Vorbis comment to bytes.

      Parameters

      • addFramingBit: boolean = false

        If true, append a 0x01 framing bit (used in Ogg Vorbis)

      Returns ByteVector

    • Replaces all complex properties for the given key.

      Parameters

      • key: string

        The complex property key (only "PICTURE" is supported).

      • value: VariantMap[]

        Array of variant maps describing each picture to embed.

      Returns boolean

      true if the key was handled, false otherwise.

    • Validate a Vorbis comment field key.

      Keys must consist only of ASCII characters in the range 0x20–0x7D, excluding '=' (0x3D), and must be at least one character long.

      Parameters

      • key: string

        The field key to validate.

      Returns boolean

      true if the key is valid.

    • 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 " / ".