Skip to main content

Function: toCommonMetadata()

function toCommonMetadata(metadata: TagMap): CommonMetadata;

Defined in: packages/player/src/common-metadata.ts:150

Normalise a raw mpv tag map into CommonMetadata.

Parameters

ParameterTypeDescription
metadataTagMapThe map from Player.getMetadata().

Returns

CommonMetadata

The normalised view. Fields with no usable tag are absent, never empty strings.

Remarks

The whole mapping table, so nothing here is a mystery. The left column is matched case-insensitively, in order, and the first non-empty tag wins:

fieldtags, in priority order
titletitle, icy-title
artistartist, author, performer
albumalbum
albumArtistalbum_artist, albumartist, album artist, tpe2
trackNumber / trackCounttrack, tracknumber, trck (+ tracktotal, totaltracks)
discNumber / discCountdisc, discnumber, tpos (+ disctotal, totaldiscs)
yeardate, year, originaldate, originalyear, tyer
genregenre, icy-genre
composercomposer
commentcomment, description
stationicy-name
streamTitleicy-title
bitrateKbpsicy-br

Everything else in the file is still in getMetadata(); this is a convenience over that map, not a filter on it. It reads the map it is given and performs no I/O, which is what makes it testable with a plain object — and why it is exported rather than hidden inside the player.