taglib-ts
    Preparing search index...

    Class FileRef

    Format-agnostic handle for an audio file.

    FileRef detects the audio format automatically (by file-name extension first, then by magic-byte content inspection) and instantiates the correct format-specific File subclass. All common tag and audio-property operations are exposed as convenience methods so that callers rarely need to interact with the underlying File directly.

    Open an audio file from a browser File object

    const ref = await FileRef.fromBlob(file, file.name);
    if (ref.isValid) {
    console.log(ref.tag()?.title);
    }
    Index

    Accessors

    • get isNull(): boolean

      true when no format was detected or the file could not be parsed.

      Returns boolean

    • get isValid(): boolean

      true when the file was detected and parsed without errors.

      Returns boolean

    Methods

    • Return all complex property values for the given key.

      Parameters

      • key: string

        The property key (e.g. "PICTURE").

      Returns VariantMap[]

      An array of VariantMap objects, or [] when no file is open.

    • Return the keys of all complex (non-string) properties stored in the file.

      Returns string[]

      An array of property key strings, or [] when no file is open.

    • The underlying format-specific file instance, or null.

      Returns File | null

    • Remove properties not supported by the underlying tag format.

      Parameters

      • props: string[]

        Keys of the properties to remove.

      Returns void

    • Write any pending tag changes back to the in-memory stream.

      Returns Promise<boolean>

      true on success, false if saving failed or no file is open.

    • Set complex property values for the given key.

      Parameters

      • key: string

        The property key (e.g. "PICTURE").

      • value: VariantMap[]

        The new values to store.

      Returns boolean

      true if stored, false if the format does not support this or no file is open.

    • The tag exposed by the underlying file, or null if unavailable.

      Returns Tag | null

    • Return the list of file extensions recognized by taglib-ts.

      Returns string[]

      An array of lowercase extension strings (without the leading dot).

    • Create a FileRef from a browser Blob or File.

      Parameters

      • blob: Blob

        The blob containing audio data.

      • Optionalfilename: string

        Optional filename override for extension-based detection. When omitted and blob is a File, blob.name is used automatically.

      • OptionalreadProperties: boolean

        When true (default), audio properties are parsed.

      • OptionalreadStyle: ReadStyle

        Controls parsing accuracy vs. performance.

      Returns Promise<FileRef>

      A resolved FileRef.

    • Create a FileRef from a raw byte array.

      Parameters

      • data: Uint8Array

        The audio data.

      • filename: string = ""

        Optional filename used for extension-based format detection (e.g. "track.mp3"). Falls back to content-based detection when empty.

      • readProperties: boolean = true

        When true (default), audio properties are parsed.

      • readStyle: ReadStyle = ReadStyle.Average

        Controls parsing accuracy vs. performance.

      Returns Promise<FileRef>

      A resolved FileRef.

    • Open an audio stream and return a FileRef.

      Parameters

      • stream: IOStream

        The audio data stream.

      • readProperties: boolean = true

        When true (default), audio properties are parsed.

      • readStyle: ReadStyle = ReadStyle.Average

        Controls parsing accuracy vs. performance.

      Returns Promise<FileRef>

      A FileRef whose isValid reflects whether the format was recognised and parsed successfully.