One Logo Pool Ball
MusicKit · IOS API REFERENCE

Song

struct · iOS 15.0+ · SDK 27.1

struct Song

A music item that represents a song.

Members (39)

get · iOS 15.0+

albumTitle

TypeScript
get albumTitle(): (string) | null
Swift declaration
var albumTitle: String? { get }

The title of the album the song appears on.

get · iOS 15.0+

artistName

TypeScript
get artistName(): string
Swift declaration
var artistName: String { get }

The artist’s name.

get · iOS 15.0+

discNumber

TypeScript
get discNumber(): (number) | null
Swift declaration
var discNumber: Int? { get }

The number of the disc the song appears on.

get · iOS 15.0+

genreNames

TypeScript
get genreNames(): Array<string>
Swift declaration
var genreNames: [String] { get }

The names of the song’s associated genres.

get · iOS 15.0+

attribution

TypeScript
get attribution(): (string) | null
Swift declaration
var attribution: String? { get }

For classical music only, the name of the artist or composer to attribute to the song.

get · iOS 15.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

get · iOS 15.0+

musicVideos

TypeScript
get musicVideos(): (MusicItemCollection<MusicVideo>) | null
Swift declaration
var musicVideos: MusicItemCollection<MusicVideo>? { get }

The song’s associated music videos.

get · iOS 15.0+

releaseDate

TypeScript
get releaseDate(): (globalThis.Date) | null
Swift declaration
var releaseDate: Date? { get }

The release date (or expected prerelease date) for the song.

get · iOS 15.0+

trackNumber

TypeScript
get trackNumber(): (number) | null
Swift declaration
var trackNumber: Int? { get }

The song’s number in the album’s track list.

get · iOS 15.0+

composerName

TypeScript
get composerName(): (string) | null
Swift declaration
var composerName: String? { get }

The name of the song’s composer.

get · iOS 15.0+

movementName

TypeScript
get movementName(): (string) | null
Swift declaration
var movementName: String? { get }

For classical music only, the movement name of this song.

get · iOS 16.0+

audioVariants

TypeScript
get audioVariants(): (Array<AudioVariant>) | null
Swift declaration
var audioVariants: [AudioVariant]? { get }

The variants that indicate the quality of audio available for the song.

get · iOS 15.0+

contentRating

TypeScript
get contentRating(): (ContentRating) | null
Swift declaration
var contentRating: ContentRating? { get }

The rating of the content. A nil value means no rating is available for this song.

get · iOS 15.0+

movementCount

TypeScript
get movementCount(): (number) | null
Swift declaration
var movementCount: Int? { get }

For classical music only, the movement count of this song.

get · iOS 15.0+

previewAssets

TypeScript
get previewAssets(): (Array<PreviewAsset>) | null
Swift declaration
var previewAssets: [PreviewAsset]? { get }

The preview assets for the song.

get · iOS 15.0+

editorialNotes

TypeScript
get editorialNotes(): (EditorialNotes) | null
Swift declaration
var editorialNotes: EditorialNotes? { get }

The editorial notes for the song.

get · iOS 16.0+

lastPlayedDate

TypeScript
get lastPlayedDate(): (globalThis.Date) | null
Swift declaration
var lastPlayedDate: Date? { get }

The date when the user last played the song on this device.

get · iOS 15.0+

movementNumber

TypeScript
get movementNumber(): (number) | null
Swift declaration
var movementNumber: Int? { get }

For classical music only, the movement number of this song.

get · iOS 15.0+

playParameters

TypeScript
get playParameters(): (PlayParameters) | null
Swift declaration
var playParameters: PlayParameters? { get }

The parameters to use to play the song.

get · iOS 15.0+

debugDescription

TypeScript
get debugDescription(): string
Swift declaration
var debugDescription: String { get }

A textual representation of this instance, suitable for debugging. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(reflecting:)` initializer. This initializer works with any type, and uses the custom `debugDescription` property for types that conform to `CustomDebugStringConvertible`: struct Point: CustomDebugStringConvertible { let x: Int, y: Int var debugDescription: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(reflecting: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `debugDescription` property.

get · iOS 16.0+

libraryAddedDate

TypeScript
get libraryAddedDate(): (globalThis.Date) | null
Swift declaration
var libraryAddedDate: Date? { get }

The date when the user added the song to the library.

get · iOS 16.0+

isAppleDigitalMaster

TypeScript
get isAppleDigitalMaster(): (boolean) | null
Swift declaration
var isAppleDigitalMaster: Bool? { get }

A Boolean value that indicates whether the song is an Apple Digital Master. Apple Digital Masters start from 24-bit files and are optimized to bring the best-sounding audio to Apple products.

get · iOS 15.0+

id

TypeScript
get id(): MusicItemID
Swift declaration
let id: MusicItemID

The unique identifier for the song.

get · iOS 15.0+

url

TypeScript
get url(): (string) | null
Swift declaration
var url: URL? { get }

The URL for the song.

get · iOS 15.0+

isrc

TypeScript
get isrc(): (string) | null
Swift declaration
var isrc: String? { get }

The International Standard Recording Code (ISRC) for the song.

get · iOS 15.0+

title

TypeScript
get title(): string
Swift declaration
var title: String { get }

The title of the song.

get · iOS 15.0+

albums

TypeScript
get albums(): (MusicItemCollection<Album>) | null
Swift declaration
var albums: MusicItemCollection<Album>? { get }

The song’s associated albums.

get · iOS 15.0+

genres

TypeScript
get genres(): (MusicItemCollection<Genre>) | null
Swift declaration
var genres: MusicItemCollection<Genre>? { get }

The song’s associated genres.

get · iOS 15.0+

artists

TypeScript
get artists(): (MusicItemCollection<Artist>) | null
Swift declaration
var artists: MusicItemCollection<Artist>? { get }

The song’s associated artists.

get · iOS 15.0+

artwork

TypeScript
get artwork(): (Artwork) | null
Swift declaration
var artwork: Artwork? { get }

The artwork for the song.

get · iOS 26.4+

endTime

TypeScript
get endTime(): (number) | null
Swift declaration
var endTime: TimeInterval? { get }

The custom end time for the song.

get · iOS 15.0+

station

TypeScript
get station(): (Station) | null
Swift declaration
var station: Station? { get }

The song’s associated station.

get · iOS 15.0+

duration

TypeScript
get duration(): (number) | null
Swift declaration
var duration: TimeInterval? { get }

The duration of the song.

get · iOS 15.0+

workName

TypeScript
get workName(): (string) | null
Swift declaration
var workName: String? { get }

For classical music only, the name of the associated work.

get · iOS 15.0+

artistURL

TypeScript
get artistURL(): (string) | null
Swift declaration
var artistURL: URL? { get }

The artist’s URL.

get · iOS 15.0+

composers

TypeScript
get composers(): (MusicItemCollection<Artist>) | null
Swift declaration
var composers: MusicItemCollection<Artist>? { get }

The song’s composers.

get · iOS 15.0+

hasLyrics

TypeScript
get hasLyrics(): boolean
Swift declaration
var hasLyrics: Bool { get }

A Boolean value that indicates whether the song has lyrics available in the catalog. If true, the song has lyrics available; otherwise, it doesn’t.

get · iOS 16.0+

playCount

TypeScript
get playCount(): (number) | null
Swift declaration
var playCount: Int? { get }

The number of times the user played the song.

get · iOS 26.4+

startTime

TypeScript
get startTime(): (number) | null
Swift declaration
var startTime: TimeInterval? { get }

The custom start time for the song.

Skipped declarations

No declarations were skipped in this snapshot.

All MusicKit types →