Class

MPMediaPlaylist

A playable collection of related media items.

Declaration

@interface MPMediaPlaylist : MPMediaItemCollection

Overview

Each playlist has a name, a set of attributes, and a unique identifier that persists across application launches.

Users configure playlists using iTunes or by creating a playlist on the device. To your iOS application, playlists are read-only. To obtain playlists, configure a media query that is grouped by playlist. Each returned media item collection is a media playlist. The following code snippet illustrates this by logging playlist and song names to the Xcode debugger console:

MPMediaQuery *myPlaylistsQuery = [MPMediaQuery playlistsQuery];
NSArray *playlists = [myPlaylistsQuery collections];
 
for (MPMediaPlaylist *playlist in playlists) {
    NSLog (@"%@", [playlist valueForProperty: MPMediaPlaylistPropertyName]);
 
    NSArray *songs = [playlist items];
    for (MPMediaItem *song in songs) {
        NSString *songTitle =
            [song valueForProperty: MPMediaItemPropertyTitle];
        NSLog (@"\t\t%@", songTitle);
    }
}

The API for building a media query is described in MPMediaPropertyPredicate and MPMediaQuery. The methods for querying media playlist property values are described in MPMediaEntity.

Topics

Adding Media Items to a Playlist

- addItemWithProductID:completionHandler:

Adds the item associated with the product identifier to the end of the playlist.

- addMediaItems:completionHandler:

Adds an array of media items to the end of the playlist.

Retrieving Information About a Playlist

authorDisplayName

App defined display name for the playlist.

descriptionText

User supplied text that describes the playlist.

name

The name of the playlist.

persistentID

The persistent identifier for the playlist.

playlistAttributes

The attributes associated with the playlist

MPMediaPlaylistAttribute

Attributes define the type of playlist.

seedItems

The items seeded to generate the playlist; applies only to Genius playlists.

Property Keys

Playlist Property Keys

Keys that contain information about a playlist.

Relationships

See Also

Media Items and Playlists

MPMediaItem

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

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.

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.