Class: MPMusicPlayerController

Inherits:
NSObject show all

Overview

Use an MPMusicPlayerController object, or music player, to play media items from the device iPod library. There are two types of music player:

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, #init, 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

- (Integer) indexOfNowPlayingItem (readonly)

The index of the now playing item in the current playback queue. This property’s value is NSNotFound if the index is not valid—for example, if the playback queue is empty.

Returns:

- (MPMediaItem) nowPlayingItem

The currently-playing media item, or the media item, within a queue, that you have designated to begin playback with. To specify that playback should begin at a particular media item in the playback queue, set this property to that item while the music player is stopped or paused.If no media item is playing or designated to play, this property’s value is nil.If you create an iPod music player and the user plays an item from another library using Home Sharing, the value of this property is nil.

Returns:

- (MPMusicPlaybackState) playbackState (readonly)

The current playback state of the music player. If you configure a music player as an iPod music player, the playback state matches the playback state of the built-in iPod app. This is true whether the iPod app is using the device iPod library or a home shared library. Note, however, that when the iPod is using a home shared library, the music player’s nowPlayingItem property is nil.For the available playback states, see “Playback States.”

Returns:

  • (MPMusicPlaybackState)

- (MPMusicRepeatMode) repeatMode

The current repeat mode of the music player. For the available repeat modes, see “Repeat Modes.” If not explicitly set, repeatMode defaults to MPMusicRepeatModeDefault.

Returns:

  • (MPMusicRepeatMode)

- (MPMusicShuffleMode) shuffleMode

The current shuffle mode of the music player. For the available shuffle modes, see “Shuffle Modes.” If not explicitly set, shuffleMode defaults to MPMusicShuffleModeDefault.

Returns:

  • (MPMusicShuffleMode)

- (Float) volume

The audio playback volume for the music player, in the range from 0.0 (silent) through 1.0 (maximum volume). A music player’s volume has a default value of 1.0.

Returns:

Class Method Details

+ (MPMusicPlayerController) applicationMusicPlayer

Returns the application music player. The application music player plays music locally within your app. It does not affect the iPod state. When your app moves to the background, the music player stops if it was playing.

Returns:

+ (MPMusicPlayerController) iPodMusicPlayer

Returns the iPod music player, which controls the iPod app’s state. The iPod music player employs the iPod app on your behalf. On instantiation, it takes on the current iPod app state and controls that state as your app runs. Specifically, the shared state includes the following:Repeat mode (see “Repeat Modes”)Shuffle mode (see “Shuffle Modes”Now-playing item (see nowPlayingItem)Playback state (see playbackState)Other aspects of iPod state, such as the on-the-go playlist, are not shared. Music that is playing continues to play when your app moves to the background.

Returns:

Instance Method Details

- (Object) beginGeneratingPlaybackNotifications

Starts the generation of playback notifications.

Returns:

- (Object) endGeneratingPlaybackNotifications

Ends the generation of playback notifications.

Returns:

- (Object) setQueueWithItemCollection(itemCollection)

Sets a music player’s playback queue using a media item collection. To begin playback after establishing a playback queue, call play.

Parameters:

Returns:

- (Object) setQueueWithQuery(query)

Sets a music player’s playback queue based on a media query. To begin playback after establishing a playback queue, call play.

Parameters:

  • query (MPMediaQuery)

    A media query that specifies the collection of media items that you want as the playback queue. See MPMediaQuery Class Reference for a description of query types and how to create them.

Returns:

- (Object) skipToBeginning

Restarts playback at the beginning of the currently playing media item.

Returns:

- (Object) skipToNextItem

Starts playback of the next media item in the playback queue; or, the music player is not playing, designates the next media item as the next to be played. If already at the last item in the playback queue when this method is called, ends playback.

Returns:

- (Object) skipToPreviousItem

Starts playback of the previous media item in the playback queue; or, the music player is not playing, designates the previous media item as the next to be played. If already at the first item in the playback queue when this method is called, ends playback.

Returns: