import { ByteVector } from "../byteVector"; import { File, ReadStyle } from "../file"; import { Frame, FrameClassType } from "./frames/frame"; import { FrameIdentifier } from "./frameIdentifiers"; import { Id3v2TagHeaderFlags } from "./id3v2TagHeader"; import { IPicture } from "../picture"; import { Tag, TagTypes } from "../tag"; /** * Extends {@link Tag} to provide support for reading and writing tags stored in the ID3v2 format. */ export default class Id3v2Tag extends Tag { private static _language; private _extendedHeader; private _frameList; private _header; private _performersRole; private constructor(); /** * Constructs and initializes an empty ID3v2 tag. */ static fromEmpty(): Id3v2Tag; /** * Constructs and initializes a new Tag by reading the contents from a specified * {@link ByteVector} object. * @param data Tag data to read into a tag object * @returns Tag with the data from the byte vector read into it */ static fromData(data: ByteVector): Id3v2Tag; /** * Constructs and initializes a new Tag by reading the beginning of the tag. * @remarks This method is the most flexible way of reading ID3v2 tags. * @param file File from which the contents of the new instance is to be read * @param position Offset into the file where the tag begins * @param style How the data is to be read into the current instance * @returns Tag with the data from the file read into it */ static fromFileStart(file: File, position: number, style: ReadStyle): Id3v2Tag; /** * Constructs and initializes a new Tag by reading the end of the tag first. * @remarks * This method should only be used if reading tags at the end of a file. Only ID3v2.4 * tags support a footer, which is required to use this method. * @param file File from which the contents of the new instance is to be read * @param position Offset into the file where the tag ends * @param style How the data is to be read into the current instance */ static fromFileEnd(file: File, position: number, style: ReadStyle): Id3v2Tag; /** * Gets the ISO-639-2 language code to use when searching for and storing language specific * values. */ static get language(): string; /** * Gets the ISO-639-2 language code to use when searching for and storing language specific * values. * @param value ISO-639-2 language code to use. If the language is unknown ` ` (that is, * three spaces) is the appropriate filler */ static set language(value: string); /** * Gets the header flags applied to the current instance. */ get flags(): Id3v2TagHeaderFlags; /** * Sets the header flags applied to the current instance * @param value Bitwise combined {@link Id3v2TagHeaderFlags} value containing flags applied to the * current instance. */ set flags(value: Id3v2TagHeaderFlags); /** * Gets all frames contained in the current instance. */ get frames(): Frame[]; /** * @inheritDoc * @remarks * This property is implemented using the TCMP Text Information Frame to provide * support for a feature of the Apple iPod and iTunes products (ie, this is a non-standard * field). */ get isCompilation(): boolean; /** * @inheritDoc * @remarks * This property is implemented using the TCMP Text Information Frame to provide * support for a feature of the Apple iPod and iTunes products (ie, this is a non-standard * field). * @param value Whether or not the album described by the current instance is a compilation */ set isCompilation(value: boolean); /** * Gets the ID3v2 version for the current instance. */ get version(): number; /** * Sets the ID3v2 version for the current instance. * @param value ID3v2 version for the current instance. Must be 2, 3, or 4. */ set version(value: number); /** @inheritDoc */ get tagTypes(): TagTypes; /** @inheritDoc */ get sizeOnDisk(): number; /** * @inheritDoc * @remarks Stored in the `TIT2` frame */ get title(): string; /** * @inheritDoc * @remarks Stored in the `TIT2` frame */ set title(value: string); /** * @inheritDoc * @remarks Stored in the `TSOT` frame */ get titleSort(): string; /** * @inheritDoc * @remarks Stored in the `TSOT` frame */ set titleSort(value: string); /** * @inheritDoc * @remarks Stored in the `TIT3` frame */ get subtitle(): string; /** * @inheritDoc * @remarks Stored in the `TIT3` frame */ set subtitle(value: string); /** * @inheritDoc * @remarks via user text frame "description" */ get description(): string; /** * @inheritDoc * @remarks via user text frame "description" */ set description(value: string); /** * @inheritDoc * @remarks Stored in the `TPE1` frame */ get performers(): string[]; /** * @inheritDoc * @remarks Stored in the `TPE1` frame */ set performers(value: string[]); /** * @inheritDoc * @remarks Stored in the `TSOP` frame */ get performersSort(): string[]; /** * @inheritDoc * @remarks Stored in the `TSOP` frame */ set performersSort(value: string[]); /** * @inheritDoc * @remarks Stored in the `TMCL` frame */ get performersRole(): string[]; /** * @inheritDoc * @remarks Stored in the `TMCL` frame */ set performersRole(value: string[]); /** * @inheritDoc * @remarks Stored in the `TSO2` frame */ get albumArtists(): string[]; /** * @inheritDoc * @remarks Stored in the `TSO2` frame */ set albumArtists(value: string[]); /** * @inheritDoc * @remarks Stored in the `TPE2` frame */ get albumArtistsSort(): string[]; /** * @inheritDoc * @remarks Stored in the `TPE2` frame */ set albumArtistsSort(value: string[]); /** * @inheritDoc * @remarks Stored in the `TCOM` frame */ get composers(): string[]; /** * @inheritDoc * @remarks Stored in the `TCOM` frame */ set composers(value: string[]); /** * @inheritDoc * @remarks Stored in the `TSOC` frame */ get composersSort(): string[]; /** * @inheritDoc * @remarks Stored in the `TSOC` frame */ set composersSort(value: string[]); /** * @inheritDoc * @remarks Stored in the `TALB` frame */ get album(): string; /** * @inheritDoc * @remarks Stored in the `TALB` frame */ set album(value: string); /** * @inheritDoc * @remarks Stored in the `TSOA` frame */ get albumSort(): string; /** * @inheritDoc * @remarks Stored in the `TSOA` frame */ set albumSort(value: string); /** * @inheritDoc * @remarks Stored in the `COMM` frame */ get comment(): string; /** * @inheritDoc * @remarks Stored in the `COMM` frame */ set comment(value: string); /** * @inheritDoc * @remarks Stored in the `TCON` frame */ get genres(): string[]; /** * @inheritDoc * @remarks Stored in the `TCON` frame */ set genres(value: string[]); /** * @inheritDoc * @remarks * If a TDRC frame exists, the year will be read from that. If a TDRC frame doesn't exist and a * TYER or TYE frame exists, the year will be read from that. Failing both cases, 0 will be * returned. */ get year(): number; /** * @inheritDoc * @remarks NOTE: values >9999 will remove the frame */ set year(value: number); /** * @inheritDoc * @remarks Stored in the `TRCK` frame */ get track(): number; /** * @inheritDoc * @remarks Stored in the `TRCK` frame */ set track(value: number); /** * @inheritDoc * @remarks Stored in the `TRCK` frame */ get trackCount(): number; /** * @inheritDoc * @remarks Stored in the `TRCK` frame */ set trackCount(value: number); /** * @inheritDoc * @remarks Stored in the `TPOS` frame */ get disc(): number; /** * @inheritDoc * @remarks Stored in the `TPOS` frame */ set disc(value: number); /** * @inheritDoc * @remarks Stored in the `TPOS` frame */ get discCount(): number; /** * @inheritDoc * @remarks Stored in the `TPOS` frame */ set discCount(value: number); /** * @inheritDoc * @remarks Stored in the `USLT` frame */ get lyrics(): string; /** * @inheritDoc * @remarks Stored in the `USLT` frame */ set lyrics(value: string); /** * @inheritDoc * @remarks Stored in the `TIT1` frame */ get grouping(): string; /** * @inheritDoc * @remarks Stored in the `TIT1` frame */ set grouping(value: string); /** * @inheritDoc * @remarks Stored in the `TBPM` frame */ get beatsPerMinute(): number; /** * @inheritDoc * @remarks Stored in the `TBPM` frame */ set beatsPerMinute(value: number); /** * @inheritDoc * @remarks Stored in the `TPE3` frame */ get conductor(): string; /** * @inheritDoc * @remarks Stored in the `TPE3` frame */ set conductor(value: string); /** * @inheritDoc * @remarks Stored in the `TCOP` frame */ get copyright(): string; /** * @inheritDoc * @remarks Stored in the `TCOP` frame */ set copyright(value: string); /** * @inheritDoc * @remarks Stored in the `TDTG` frame */ get dateTagged(): Date | undefined; /** * @inheritDoc * @remarks Stored in the `TDTG` frame */ set dateTagged(value: Date | undefined); /** * @inheritDoc * @remarks via TXXX:MusicBrainz Artist Id frame */ get musicBrainzArtistId(): string; /** * @inheritDoc * @remarks via TXXX:MusicBrainz Artist Id frame */ set musicBrainzArtistId(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Release Group Id` frame */ get musicBrainzReleaseGroupId(): string; /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Release Group Id` frame */ set musicBrainzReleaseGroupId(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Id` frame */ get musicBrainzReleaseId(): string; /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Id` frame */ set musicBrainzReleaseId(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Artist Id` frame */ get musicBrainzReleaseArtistId(): string; /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Artist Id` frame */ set musicBrainzReleaseArtistId(value: string); /** * @inheritDoc * @remarks via a UFID `http://musicbrainz.org` frame */ get musicBrainzTrackId(): string; /** * @inheritDoc * @remarks via a UFID `http://musicbrainz.org` frame */ set musicBrainzTrackId(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Disc Id` frame */ get musicBrainzDiscId(): string; /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Disc Id` frame */ set musicBrainzDiscId(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicIP PUID` frame */ get musicIpId(): string; /** * @inheritDoc * @remarks via a TXXX `MusicIP PUID` frame */ set musicIpId(value: string); /** * @inheritDoc * @remarks via a TXXX `ASIN` frame */ get amazonId(): string; /** * @inheritDoc * @remarks via a TXXX `ASIN` frame */ set amazonId(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Status` frame */ get musicBrainzReleaseStatus(): string; /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Status` frame */ set musicBrainzReleaseStatus(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Type` frame */ get musicBrainzReleaseType(): string; /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Type` frame */ set musicBrainzReleaseType(value: string); /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Release Country` frame */ get musicBrainzReleaseCountry(): string; /** * @inheritDoc * @remarks via a TXXX `MusicBrainz Album Release Country` frame */ set musicBrainzReleaseCountry(value: string); /** * @inheritDoc * @remarks via a TXXX `REPLAY_GAIN_TRACK_GAIN` frame */ get replayGainTrackGain(): number; /** * @inheritDoc * @remarks via a TXXX `REPLAY_GAIN_TRACK_GAIN` frame */ set replayGainTrackGain(value: number); /** * @inheritDoc * @remarks via a TXXX `REPLAYGAIN_TRACK_PEAK` frame */ get replayGainTrackPeak(): number; /** * @inheritDoc * @remarks via a TXXX `REPLAYGAIN_TRACK_PEAK` frame */ set replayGainTrackPeak(value: number); /** * @inheritDoc * @remarks via a TXXX `REPLAYGAIN_ALBUM_GAIN` frame */ get replayGainAlbumGain(): number; /** * @inheritDoc * @remarks via a TXXX `REPLAYGAIN_ALBUM_GAIN` frame */ set replayGainAlbumGain(value: number); /** * @inheritDoc * @remarks via a TXXX `REPLAYGAIN_ALBUM_PEAK` frame */ get replayGainAlbumPeak(): number; /** * @inheritDoc * @remarks via a TXXX `REPLAYGAIN_ALBUM_PEAK` frame */ set replayGainAlbumPeak(value: number); /** * @inheritDoc * @remarks Stored in the `TKEY` frame */ get initialKey(): string; /** * @inheritDoc * @remarks Stored in the `TKEY` frame */ set initialKey(value: string); /** * @inheritDoc * @remarks Stored in the `TPE4` frame */ get remixedBy(): string; /** * @inheritDoc * @remarks Stored in the `TPE4` frame */ set remixedBy(value: string); /** * @inheritDoc * @remarks Stored in the `TPUB` frame */ get publisher(): string; /** * @inheritDoc * @remarks Stored in the `TPUB` frame */ set publisher(value: string); /** * @inheritDoc * @remarks Stored in the `TSRC` frame */ get isrc(): string; /** * @inheritDoc * @remarks Stored in the `TSRC` frame */ set isrc(value: string); /** * @inheritDoc * @remarks Stored in the `APIC` frame */ get pictures(): IPicture[]; /** * @inheritDoc * @remarks Stored in the `APIC` frame */ set pictures(value: IPicture[]); /** @inheritDoc */ get isEmpty(): boolean; /** * Adds a frame to the current instance. * @param frame Frame to add to the current instance */ addFrame(frame: Frame): void; /** @inheritDoc */ clear(): void; /** @inheritDoc */ copyTo(target: Tag, overwrite: boolean): void; /** * Gets all frames with a specific frame class type. * NOTE: This diverges from the .NET implementation due to the inability to do type checking * like in .NET (ie `x is y`). Instead, type guards are added to each frame class which provides * the same functionality. * @param type Class type of the frame to find * @returns TFrame[] Array of frames with the specified class type */ getFramesByClassType(type: FrameClassType): TFrame[]; /** * Gets a list of frames with the specified identifier contained in the current instance. * NOTE: This implementation deviates a bit from the original .NET implementation due to the * inability to do `x is y` comparison by types in typescript without type guards. * `type` is the type guard for differentiating frame types. If all frames are needed * use {@link frames}. * @param type Type of frame to return * @param ident Identifier of the frame * @returns TFrame[] Array of frames with the desired frame identifier */ getFramesByIdentifier(type: FrameClassType, ident: FrameIdentifier): TFrame[]; /** * Gets the text value from a specified text information frame (or URL frame if that was * specified). * @param ident Frame identifier of the text information frame to get the value from * @returns Text of the specified frame, or `undefined` if no value was found */ getTextAsString(ident: FrameIdentifier): string; /** * Removes a specified frame from the current instance. * @param frame Object to remove from the current instance */ removeFrame(frame: Frame): void; /** * Removes all frames with a specified identifier from the current instance. * @param ident Identifier of the frames to remove */ removeFrames(ident: FrameIdentifier): void; /** * Renders the current instance as a raw ID3v2 tag. * By default, tags will be rendered in the version they were loaded in and new tags using the * version specified by {@link defaultVersion}. If {@link forceDefaultVersion} is `true`, all * tags will be rendered using that version, except for tags with footers which must be in * version 4. * @returns The rendered tag. */ render(): ByteVector; /** * Replaces an existing frame with a new one in the list contained in the current instance, or * adds a new one if the existing one is not contained. * @param oldFrame Object to be replaced * @param newFrame Object to replace `oldFrame` with */ replaceFrame(oldFrame: Frame, newFrame: Frame): void; /** * Sets the numerical values for a specified text information frame. * If both `numerator` and `denominator` are `0`, the frame will be removed * from the tag. If `denominator` is zero, `numerator` will be stored by * itself. Otherwise, the values will be stored as `{numerator}/{denominator}`. * @param ident Identity of the frame to set * @param numerator Value containing the top half of the fraction, or the number if * `denominator` is zero * @param denominator Value containing the bottom half of the fraction * @param minPlaces Minimum number of digits to use to display the `numerator`, if * the numerator has less than this number of digits, it will be filled with leading zeroes. */ setNumberFrame(ident: FrameIdentifier, numerator: number, denominator: number, minPlaces?: number): void; /** * Sets the text for a specified text information frame. * @param ident Identifier of the frame to set the data for * @param text Text to set for the specified frame or `undefined`/`null`/`""` to remove all * frames with that identifier. */ setTextFrame(ident: FrameIdentifier, ...text: string[]): void; private parse; private readFromStart; private readFromEnd; private getTextAsArray; private getTextAsUint32; private getUfidText; private getUserTextAsString; private setUfidText; private setUserTextAsString; }