MPMediaItemCollection Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/MediaPlayer.framework |
| Availability | Available in iOS 3.0 and later. |
| Companion guide | |
| Declared in | MPMediaItemCollection.h |
Overview
A media item collection is a sorted set of media items (instances of the MPMediaItem class) from the iPod library. Typically, you use this class by requesting an array of collections from a media query by way of its collections property. Media queries are described in MPMediaQuery Class Reference.
The grouping type for the media query determines the arrangement of the media items you obtain. You also use the media query collections property to obtain synced playlists, as described in MPMediaPlaylist Class Reference.
A media item collection 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. The You can also access metadata in a batch fashion using the enumerateValuesForProperties:usingBlock: method. In some cases, this is more efficient. Both of these methods are defined in MPMediaEntity (the abstract superclass of MPMediaItemCollection) and described in MPMediaEntity Class Reference.
Tasks
Creating a Media Item Collection
Using a Media Item Collection
-
itemsproperty -
representativeItemproperty -
countproperty -
mediaTypesproperty
Properties
count
The number of media items in a collection.
Discussion
In some cases, using this property is more efficient than fetching the items array and asking for the count.
Availability
- Available in iOS 3.0 and later.
Declared In
MPMediaItemCollection.hitems
The media items in a media item collection.
Availability
- Available in iOS 3.0 and later.
Declared In
MPMediaItemCollection.hmediaTypes
The types of the media items in a collection.
Discussion
The media item types are listed in the Media Item Type Flags enumeration in MPMediaItem Class Reference.
Availability
- Available in iOS 3.0 and later.
Declared In
MPMediaItemCollection.hrepresentativeItem
A media item whose properties are representative of the other media items in a collection.
Discussion
The media items in a collection typically share common property values, owing to how the collection was built. For example, if you build a collection based on a predicate that uses the MPMediaItemPropertyArtist property, all items in the collection share the same artist name. You can use the representativeItem property to efficiently obtain values for such common properties—often more efficiently than fetching an item from the items array.
Availability
- Available in iOS 3.0 and later.
Declared In
MPMediaItemCollection.hClass Methods
collectionWithItems:
Creates a media item collection by copying an array of media items.
Parameters
- items
The array of media items you are assigning to the media item collection.
Return Value
A media item collection.
Availability
- Available in iOS 3.0 and later.
Declared In
MPMediaItemCollection.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-11-15)