Content types and metadata
Describe the media your app is playing.
Overview
Use content types to tell the system what kind of media your app is playing. Each content type provides metadata fields appropriate for its media category, such as the song title and artist for music, or the show name and season for TV episodes.
Return a content type from your content or content property. The framework uses this information to populate the Lock Screen, Control Center, and connected accessories.
Each content type has a small set of initializer parameters for its core metadata, plus mutable properties for additional fields like isExplicit, genre, collectionID, and serviceID. Set those properties on the content value before returning it:
var content: (any MediaContentRepresentable)? {
guard let track = currentTrack else { return nil }
var content = MusicContent(
id: track.id,
songTitle: track.title,
artistName: track.artist,
albumName: track.album,
type: .audio,
duration: .finite(track.duration),
artwork: Artwork(id: track.artworkID) { size in
let (data, _) = try await URLSession.shared.data(from: track.artworkURL)
return try ArtworkRepresentation(data: data)
}
)
content.isExplicit = track.isExplicit
content.genre = track.genre
return content
}Topics
Presenting content
MediaContentRepresentableMusicContentPodcastContentMovieContentTVShowContentBookContentRadioContentHomeMediaContentGenericContent