export type UnknownArtistGetter = string | (() => string); export type PictureDataType = Uint8Array | string; export type IPictureTemplate = { /** * - The MIME type of the image (e.g., 'image/jpeg'). */ format: string; /** * - The raw binary data of the image. */ data: PictureData; /** * - An optional textual description of the image. */ description?: string; /** * - The specific type of picture (e.g., 'cover', 'front', 'back'). */ type?: string; /** * - The filename associated with the image. */ name?: string; }; export type IPicture = IPictureTemplate; export type MediaNumber = { no?: number; of?: number; }; export type IComment = { /** * - A descriptor for the comment. */ descriptor?: string; /** * - The language of the comment. */ language?: string; /** * - The text content of the comment. */ text?: string; }; export type ILyricsText = { /** * - The lyric text content. */ text?: string; /** * - The timestamp associated with this lyric line. */ timestamp?: number; }; export type TimestampFormat = { /** * - Indicates if the timestamp is not synchronized. */ notSynchronized?: number; /** * - The MPEG frame number. */ mpegFrameNumber?: number; /** * - The time in milliseconds. */ milliseconds?: number; }; export type LyricsContentType = { /** * - Content type for other. */ other?: number; /** * - Content type for lyrics. */ lyrics?: number; /** * - Content type for text. */ text?: number; /** * - Content type for movement parts. */ movement_part?: number; /** * - Content type for events. */ events?: number; /** * - Content type for chords. */ chord?: number; /** * - Content type for trivia/pop. */ trivia_pop?: number; }; export type ILyricsTag = { /** * - The text content of the lyrics. */ text?: string; /** * - A descriptor for the lyrics. */ descriptor?: string; /** * - The language of the lyrics. */ language?: string; /** * - An array of synchronized lyric text objects. */ syncText?: ILyricsText[]; /** * - The format of the timestamp. */ timeStampFormat?: TimestampFormat; /** * - The type of lyrical content. */ contentType?: LyricsContentType; }; export type IRating = { /** * - The source of the rating. */ source?: string; /** * - The numeric rating value. */ rating?: number; }; export type ContentMetadataTemplate> = { _fetchData?: MediaContentFetchData | null; /** * - The title of the track. */ title?: string; /** * - The name of the album. */ album?: string; /** * - The primary artist of the album. */ albumartist?: string; /** * - An array of artists associated with the album. */ albumartists?: string[]; /** * - An array of genres associated with the track. */ genre?: string[]; /** * - The record label. */ label?: string[]; /** * - The composer of the track. */ composer?: string[]; /** * - The release year. */ year?: number; /** * - The primary artist of the track. */ artist?: string; /** * - An array of artists associated with the track. */ artists?: string[]; /** * - Disk information containing the current disk number and total disks. */ disk?: MediaNumber; /** * - Track information containing the current track number and total tracks. */ track?: MediaNumber; /** * - An array of picture objects containing album art. */ picture?: IPictureContent[]; /** * - The date. */ date?: string; /** * - The original date. */ originaldate?: string; /** * - The original release year. */ originalyear?: number; /** * - The release date. */ releasedate?: string; /** * - An array of comments. */ comment?: IComment[]; /** * - An array of lyric tags. */ lyrics?: ILyricsTag[]; /** * - The sortable album name. */ albumsort?: string; /** * - The sortable title. */ titlesort?: string; /** * - The work/composition name. */ work?: string; /** * - The sortable artist name. */ artistsort?: string; /** * - The sortable album artist name. */ albumartistsort?: string; /** * - The sortable composer name. */ composersort?: string; /** * - An array of lyricists. */ lyricist?: string[]; /** * - An array of writers. */ writer?: string[]; /** * - An array of conductors. */ conductor?: string[]; /** * - An array of remixers. */ remixer?: string[]; /** * - An array of arrangers. */ arranger?: string[]; /** * - An array of engineers. */ engineer?: string[]; /** * - An array of publishers. */ publisher?: string[]; /** * - An array of producers. */ producer?: string[]; /** * - An array of DJ mixers. */ djmixer?: string[]; /** * - An array of mixers. */ mixer?: string[]; /** * - An array of technicians. */ technician?: string[]; /** * - The grouping name. */ grouping?: string; /** * - An array of subtitles. */ subtitle?: string[]; /** * - An array of descriptions. */ description?: string[]; /** * - A long description. */ longDescription?: string; /** * - An array of disc subtitles. */ discsubtitle?: string[]; /** * - Total number of tracks. */ totaltracks?: string; /** * - Total number of discs. */ totaldiscs?: string; /** * - Total number of movements. */ movementTotal?: number; /** * - Whether it is a compilation. */ compilation?: boolean; /** * - An array of ratings. */ rating?: IRating[]; /** * - Beats per minute. */ bpm?: number; /** * - The mood of the track. */ mood?: string; /** * - The media type. */ media?: string; /** * - An array of catalog numbers. */ catalognumber?: string[]; /** * - The TV show name. */ tvShow?: string; /** * - The sortable TV show name. */ tvShowSort?: string; /** * - The TV season number. */ tvSeason?: number; /** * - The TV episode number. */ tvEpisode?: number; /** * - The TV episode ID. */ tvEpisodeId?: string; /** * - The TV network. */ tvNetwork?: string; /** * - Whether it is a podcast. */ podcast?: boolean; /** * - The podcast URL. */ podcasturl?: string; /** * - The release status. */ releasestatus?: string; /** * - An array of release types. */ releasetype?: string[]; /** * - The release country. */ releasecountry?: string; /** * - The script. */ script?: string; /** * - The language. */ language?: string; /** * - The copyright information. */ copyright?: string; /** * - The license information. */ license?: string; /** * - The encoder. */ encodedby?: string; /** * - The encoder settings. */ encodersettings?: string; /** * - Whether it is gapless. */ gapless?: boolean; /** * - The barcode. */ barcode?: string; /** * - An array of ISRC codes. */ isrc?: string[]; /** * - The ASIN. */ asin?: string; /** * - The website. */ website?: string; /** * - An array of performers and their instruments. */ performer_instrument?: string[]; /** * - The average loudness level. */ averageLevel?: number; /** * - The peak loudness level. */ peakLevel?: number; /** * - An array of notes. */ notes?: string[]; /** * - The original album. */ originalalbum?: string; /** * - The original artist. */ originalartist?: string; /** * - The initial key of the music in the file, e.g. "A Minor". */ key?: string; /** * - An array of categories. */ category?: string[]; /** * - HD video flag. */ hdVideo?: number; /** * - An array of keywords. */ keywords?: string[]; /** * - The movement. */ movement?: string; /** * - The movement index. */ movementIndex?: MediaNumber; /** * - The podcast ID. */ podcastId?: string; /** * - Whether to show movement. */ showMovement?: boolean; /** * - The stik value. */ stik?: number; /** * - The play counter. */ playCounter?: number; }; export type MediaContentFetchNativeData = { /** * - The unique identifier for the native data. */ id: string; /** * - The actual data value. */ value?: any | Record; }; export type ICommonTagsResult = Record & ContentMetadataTemplate>; export type INativeTags = Record; export type MediaContentFetchData = { /** * - The common metadata properties. */ common: ICommonTagsResult; /** * - The native metadata properties. */ native: INativeTags; /** * - The format of the media. */ format: unknown; /** * - The quality of the media. */ quality: unknown; }; export type MediaContentMetadata = ContentMetadataTemplate>; export type MediaContentBase = { /** * - Unique identifier. */ id: string; /** * - Media type (e.g., video, audio). */ mediaType?: string; /** * - Name of the track/message. */ title: string; /** * - Artist or speaker name. */ artist: string; /** * - Duration in milliseconds. */ duration: number; /** * - Source URL/Path. */ url: string; /** * - Probability multiplier for random selection mode. */ weight?: number; }; export type MediaContent = MediaContentBase & MediaContentMetadata; export type ParseMediaContentMetadata = (data: Blob) => Promise>; export type LoadingMediaProgress = { /** * - The current status of the operation. */ status: 'loading' | 'success'; /** * - The current execution stage. */ stage: LoadingProgressStage; /** * - The current loading event. */ event?: ProgressEvent; /** * - The URL being processed. */ url: string; }; export type LoadingProgressStage = 'INITIALIZING' | 'DOWNLOADING' | 'METADATA_LOADED' | 'EXTRACTING_ID3' | 'COMPLETE'; export type LoadingErrorStage = 'INITIALIZING' | 'DOWNLOADING' | 'METADATA' | 'ID3' | 'UNKNOWN'; export type MediaLoadingErrorData = { /** * - The original error object. */ error: Error; /** * - The URL that failed. */ url: string; /** * - The stage where it failed. */ stage: LoadingErrorStage; }; /** @type {Map} */ export declare const _blobCounter: Map; /** * Returns a new object initialized with the default values for the core media content properties. * @returns {MediaContentBase} */ export declare const getMediaContentBase: () => MediaContentBase; /** * Custom error class to provide detailed context during the content preparation process. * @extends Error */ export declare class MediaLoadingError extends Error { url: string; stage: LoadingErrorStage; /** * @param {string} message - Human-readable error message. * @param {string} url - The URL that caused the error. * @param {LoadingErrorStage} stage - The stage where the error occurred. */ constructor(message: string, url: string, stage: LoadingErrorStage); } /** * Internal helper to generate a deterministic ID from a string. * @param {string} str * @returns {Promise} * @private */ export declare const generateSimpleHash: (str: string) => Promise; /** * Helper to convert Uint8Array or Base64 string directly into a high performance Blob URL. * @param {PictureDataType} data * @param {string} format * @returns {string} The generated Blob URL or original string if already valid. */ export declare const convertToBlobUrl: (data: PictureDataType, format?: string) => string; /** * Asynchronous helper to convert a Blob URL back to Base64 (Date URL) at export time. * @param {string} url * @returns {Promise} */ export declare const blobUrlToBase64: (url: string) => Promise; /** * Safely revokes Blob URLs to prevent memory leaks from createObjectURL. * @template {PictureDataType} PictureData * @param {MediaContent} content */ export declare const revokeContentUrls: (content: MediaContent) => void; /** * @param {MediaContentFetchData|null} [fetchData] - The fetch object to be validated. * @param {boolean} [returnsBoolean=false] - Ignores the throw error to return a boolean. * @returns {boolean} */ export declare const valFetchMediaContent: (fetchData?: MediaContentFetchData | null, returnsBoolean?: boolean) => boolean; /** * Central logic of metadata validation. * @param {ContentMetadataTemplate>} common - The object to be validated. */ export declare const valMediaContentMetadata: (common: ContentMetadataTemplate>) => void; /** * Downloads an audio file from a URL and extracts its ID3/metadata tags. * * @param {string} url - The full URL of the audio file to be downloaded. * @param {ParseMediaContentMetadata} parseFile - The function used to parse the file data. * @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method. * @returns {Promise>} A promise that resolves to an object containing the extracted metadata. * @throws {TypeError} If the provided `url` is not a string or `parseFile` is not a function. * @throws {Error} If the network request fails or the parsing process encounters an error. */ export declare const extractMediaId3Tags: (url: string, parseFile: ParseMediaContentMetadata, convertBase64toBlob?: boolean) => Promise>; /** * A Static Factory Method that prepares a MediaContent object by * extracting metadata from an audio source. * * @template {PictureDataType} PictureData * @param {string | HTMLMediaElement} source - A URL string or an existing Audio object. * @param {Partial> & { id?: string; weight?: number }} [defaultMetadata={}] - Optional default metadata that overrides automatic extraction. * @param {Partial> & { id?: string; weight?: number }} [metadata={}] - Optional manual metadata that overrides automatic extraction. * @param {ParseMediaContentMetadata} [parseFile] - Private helper to interface with parseFile. * @param {Object} [callbacks={}] - Callbacks for monitoring the loading process. * @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes. * @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs. * @param {boolean} [convertBase64toBlob=true] - If the image content needs to be converted directly into a high-performance Blob URL, use this method. * @param {UnknownArtistGetter} unknownArtist * @returns {Promise>} A promise that resolves to a valid MediaContent object. * @throws {MediaLoadingError} If the preparation process fails at any stage. * * @example * // Usage with URL * import { parseBlob } from 'music-metadata'; * const track = await parseMediaMetadata('/assets/song.mp3', {}, { title: 'My Song', artist: 'Artist' }, parseBlob); * media.add('music', track); * * @example * // Usage with Audio Object * import { parseBlob } from 'music-metadata'; * const audio = new Audio(); * audio.src = '/assets/song.mp3'; * const track = await parseMediaMetadata(audio, {}, {}, parseBlob); * media.add('music', track); * * @example * // Usage with tracking * const track = await parseMediaMetadata( * '/assets/song.mp3', * {}, * {}, * parseBlob, * { * onProgress: (p) => console.log(`[${p.stage}] ${p.status}`), * onError: (e) => console.error(`Failed at ${e.stage} for ${e.url}: ${e.error.message}`) * } * ); */ export declare const parseMediaMetadata: (source: string | HTMLMediaElement, defaultMetadata?: Partial> & { id?: string; weight?: number; }, metadata?: Partial> & { id?: string; weight?: number; }, parseFile?: ParseMediaContentMetadata, callbacks?: { onProgress?: (progress: LoadingMediaProgress) => void; onError?: (error: MediaLoadingErrorData) => void; }, convertBase64toBlob?: boolean, unknownArtist?: UnknownArtistGetter) => Promise>; //# sourceMappingURL=mediaContent.d.mts.map