AudioFileTags

data class AudioFileTags(val title: String? = null, val artist: String? = null, val album: String? = null, val trackNumber: Int? = null, val genre: String? = null, val year: Int? = null, val albumArt: ByteArray? = null)

Metadata tags associated with an audio file.

All properties are optional and default to null; a file may contain none, some, or all of these tags. The albumArt field, when present, contains the raw bytes of an embedded image (typically JPEG or PNG).

Tags can be read from existing files via AudioFileReader and AudioFileInfo.tags, or written into new files by passing an instance to the AudioFileWriter constructor.

Because albumArt is a ByteArray, this class provides custom equals and hashCode implementations that compare array contents rather than references.

Usage

// Reading tags from a file
val reader = AudioFileReader("/path/to/song.mp3")
val tags = reader.info.tags
println("Now playing: ${tags.title} by ${tags.artist}")
reader.close()

// Creating tags for a new file
val tags = AudioFileTags(
title = "My Song",
artist = "My Artist",
album = "My Album",
year = 2025,
)

See also

Constructors

Link copied to clipboard
constructor(title: String? = null, artist: String? = null, album: String? = null, trackNumber: Int? = null, genre: String? = null, year: Int? = null, albumArt: ByteArray? = null)

Properties

Link copied to clipboard

The album name, or null if not present.

Link copied to clipboard

Raw bytes of the embedded album artwork image, or null if absent.

Link copied to clipboard

The performing artist name, or null if not present.

Link copied to clipboard

The genre of the track as a free-form string, or null if not present.

Link copied to clipboard

The track title, or null if not present in the file.

Link copied to clipboard

The track number within the album, or null if not present.

Link copied to clipboard
val year: Int?

The release year, or null if not present.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int