Class

MPMediaItem

A collection of properties that represents a single item contained in the media library.

Declaration

@interface MPMediaItem : MPMediaEntity

Overview

A media item has an overall unique identifier, accessed using the MPMediaItemPropertyPersistentID property key, as well as specific identifiers for its metadata. These identifiers persists across application launches.

A media item can have a wide range of metadata associated with it. You access this metadata using the valueForProperty: method along with the property keys described in this document. You can also access metadata in a batch fashion using the enumerateValuesForProperties:usingBlock: method. Anytime the app accesses more than one property, enumerating over a set of property keys is more efficient than fetching each individual property. Both of these methods are defined in MPMediaEntity, the abstract superclass of MPMediaItemCollection, and described in MPMediaEntity.

You use attributes of media items to build media queries for searching the Media library. These attributes are described in MPMediaType, General Media Item Property Keys, and Podcast Item Property Keys. In addition, the MPMediaEntityPropertyPersistentID property is described in Media Entity Property Keys. Media queries are described in MPMediaQuery.

Topics

Media Item Properties

albumArtist

The primary performing artist for an album as a whole.

albumArtistPersistentID

The persistent identifier for the primary performing artist for an album as a whole.

albumPersistentID

The persistent identifier for an album.

albumTitle

The title of an album, such as “Live On Mars”, as opposed to the title of an individual song on the album, such as “Crater Dance (radio edit)”.

albumTrackCount

The number of tracks in the album that contains the media item.

albumTrackNumber

The track number of the media item, for a media item that is part of an album.

artist

The performing artist(s) for a media item—which may vary from the primary artist for the album that a media item belongs to.

artistPersistentID

The persistent identifier for an artist.

artwork

The artwork image for the media item.

assetURL

The URL pointing to the media item.

beatsPerMinute

The number of musical beats per minute for the media item.

bookmarkTime

The user’s place in the media item the most recent time it was played.

cloudItem

A Boolean value indicating whether the media item is an iCloud Music Library item.

comments

Textual information about the media item.

compilation

A Boolean value indicating whether the media item is part of a compilation.

composer

The musical composer for the media item.

composerPersistentID

The persistent identifier for a composer.

dateAdded

The date the item was added to the library.

discCount

The number of discs in the album that contains the media item.

discNumber

The disc number of the media item, for a media item that is part of a multi-disc album.

explicitItem

A Boolean value that indicates whether the item has explicit (adult) lyrics or language.

genre

The musical or film genre of the media item.

genrePersistentID

The persistent identifier for a genre.

lastPlayedDate

The date a media item was last played.

lyrics

The lyrics for the media item.

mediaType

The media type of the media item.

persistentID

The persistent identifier for the media item.

playCount

The number of times the user has played the media item.

playbackDuration

The playback duration of the media item.

playbackStoreID

The non-library identifier for a media item.

podcastPersistentID

The persistent identifier for an audio podcast.

podcastTitle

The title of a podcast, such as “This Martian Drudgery”, as opposed to the title of an individual episode of a podcast such as “Episode 12: Another Cold Day At The Pole”.

protectedAsset

A Boolean indicating whether the media item has a protected asset.

rating

The user-specified rating of the object in the range [0...5], where a value of 5 indicates the most favorable rating.

releaseDate

The date on which the media item was first publicly released.

skipCount

The number of times the user has skipped playing the item.

title

The title (or name) of the media item.

userGrouping

Grouping information for the media item.

Obtaining Group Properties

+ persistentIDPropertyForGroupingType:

Obtains the persistent identifier key for a specified grouping type.

+ titlePropertyForGroupingType:

Obtains the title key for a specified grouping type.

Media Item Types and Keys

MPMediaType

The properties used to define the type for a media item.

General Media Item Property Keys

System defined properties used to obtain the metadata for a media item.

User-Defined Property Keys

Contains properties used to obtain user-defined metadata for a media item.

Relationships

Inherits From

See Also

Media Items and Playlists

MPMediaItemArtwork

A graphical image, such as music album cover art, associated with a media item.

MPMediaItemCollection

A sorted set of media items from the media library.

MPMediaPlaylist

A playable collection of related media items.

MPMediaPlaylistCreationMetadata

A set of attributes used to describe a playlist when the playlist is first created.

MPMediaEntity

The abstract superclass for media items, media item collections, and media playlist instances.