Class: MPMediaQuery

Inherits:
NSObject show all

Overview

A media query specifies a set of media items (instances of MPMediaItem) from the iPod library by way of a filter and a grouping type. Filter and grouping type are both optional; an unqualified query matches the entire library.

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Array) collections (readonly)

An array of media item collections whose contained items match the query’s media property predicate. The returned array of collections are grouped and sorted by the groupingType of the media query. The following code snippet illustrates how to use this property:Each element of the collections array now contains a media item collection. Each collection contains the media items from the iPod library by a particular artist. The elements of the array are sorted by artist name.For the available grouping types, see “Media Item Collection Grouping Keys.”

Returns:

- (Array) collectionSections (readonly)

An array of MPMediaQuerySection instances representing the section grouping of the query's specified media item collections. The value of this property may be nil if there is no appropriate section grouping of the media item collections.

Returns:

- (NSSet) filterPredicates

The media property predicates of the media query. The General Media Item Property Keys and Podcast Item Property Keys enumerations in MPMediaItem Class Reference contain the keys you can use to construct predicates.

Returns:

- (MPMediaGrouping) groupingType

The grouping for collections retrieved with the media query. The default grouping type is MPMediaGroupingTitle. See “Media Item Collection Grouping Keys” for the list of available grouping types.

Returns:

  • (MPMediaGrouping)

- (Array) items (readonly)

An array of media items that match the media query’s predicate. If no items match the predicate, this method returns an empty array. On error, returns nil.

Returns:

- (Array) itemSections (readonly)

An array of MPMediaQuerySection instances representing the section grouping of the query's specified media items. The value of this property may be nil if there is no appropriate section grouping of the media items.

Returns:

Class Method Details

+ (MPMediaQuery) albumsQuery

Creates a media query that matches music items and that groups and sorts collections by album name. A media item can have more than one media type; for example, an item could be of types “music” and “podcast.” An albumsQuery query matches all MPMediaTypeMusic items, whether or not they are also of other media types.

Returns:

  • (MPMediaQuery)

    A media query that matches media items of type MPMediaTypeMusic and has a grouping type of MPMediaGroupingAlbum.

+ (MPMediaQuery) artistsQuery

Creates a media query that matches music items and that groups and sorts collections by artist name. A media item can have more than one media type; for example, an item could be of types “music” and “podcast.” An artistsQuery query matches all MPMediaTypeMusic items, whether or not they are also of other media types.

Returns:

  • (MPMediaQuery)

    A media query that matches media items of type MPMediaTypeMusic and has a grouping type of MPMediaGroupingArtist.

+ (MPMediaQuery) audiobooksQuery

Creates a media query that matches audio book items and that groups and sorts collections by audio book name. A media item can have more than one media type; for example, an item could be of types “music” and “podcast.” An audiobooksQuery query matches all MPMediaTypeAudioBook items, whether or not they are also of other media types.

Returns:

  • (MPMediaQuery)

    A media query that matches media items of type MPMediaTypeAudioBook and that uses the default grouping type of MPMediaGroupingTitle.

+ (MPMediaQuery) compilationsQuery

Creates a media query that matches compilation items and that groups and sorts collections by album name. A media item can have more than one media type; for example, an item could be of types “music” and “podcast.” A compilationsQuery query matches all media items that have the MPMediaItemPropertyIsCompilation property, irrespective of their media types.

Returns:

  • (MPMediaQuery)

    A media query that matches any media item that has the MPMediaItemPropertyIsCompilation property; the returned query has a grouping type of MPMediaGroupingAlbum.

+ (MPMediaQuery) composersQuery

Creates a media query that matches all media items and that groups and sorts collections by composer name.

Returns:

  • (MPMediaQuery)

    A media query that matches all media items and that has a grouping type of MPMediaGroupingComposer.

+ (MPMediaQuery) genresQuery

Creates a media query that matches all media items and that groups and sorts collections by genre name.

Returns:

  • (MPMediaQuery)

    A media query that matches all media items and that has a grouping type of MPMediaGroupingGenre.

+ (MPMediaQuery) playlistsQuery

Creates a media query that matches the entire iPod library and that groups and sorts collections by playlist name.

Returns:

  • (MPMediaQuery)

    A media query that matches all media items and that has a grouping type of MPMediaGroupingPlaylist.

+ (MPMediaQuery) podcastsQuery

Creates a media query that matches podcast items and that groups and sorts collections by podcast name. A media item can have more than one media type; for example, an item could be of types “music” and “podcast.” A podcastsQuery query matches all MPMediaTypePodcast items, whether or not they are also of other media types.

Returns:

  • (MPMediaQuery)

    A media query that matches media items of type MPMediaTypePodcast and that has a grouping type of MPMediaGroupingPodcastTitle.

+ (MPMediaQuery) songsQuery

Creates a media query that matches music items and that groups and sorts collections by song name. A media item can have more than one media type; for example, an item could be of types “music” and “podcast.” A songsQuery query matches all MPMediaTypeMusic items, whether or not they are also of other media types.

Returns:

  • (MPMediaQuery)

    A media query that matches media items of type MPMediaTypeMusic and has a grouping type of MPMediaGroupingTitle.

Instance Method Details

- (Object) addFilterPredicate(predicate)

Adds a media property predicate to a query.

Parameters:

  • predicate (MPMediaPredicate)

    The media predicate to add to the set of predicates for the query.

Returns:

- (Object) init

Initializes a generic media query. A generic media query has no filter predicates and no grouping configuration. It matches everything in the iPod library and provides no grouping or sorting.

Returns:

- (Object) initWithFilterPredicates(filterPredicates)

Initializes a media query with a set of media property predicates. MPMediaPropertyPredicate Class Reference describes how to create media property predicates. The General Media Item Property Keys and Podcast Item Property Keys enumerations in MPMediaItem Class Reference contain the keys you can use to construct predicates.

Parameters:

  • filterPredicates (NSSet)

    The set of media property predicates to use as a filter on the iPod library.

Returns:

  • (Object)

    An initialized media query.

- (Object) removeFilterPredicate(predicate)

Removes a filter predicate from a query.

Parameters:

  • predicate (MPMediaPredicate)

    The media predicate to remove from the set of predicates for the query.

Returns: