music

Playing music

music.set_queue_with_items

Sets a music player’s playback queue using a media item collection.

music.set_queue_with_store_ids

Sets a music player's playback queue using with media items identified by the store identifiers.

music.play

Initiates playback of the current item.

music.stop

Ends playback of the current item.

music.restart

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

music.next

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.

music.previous

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.

music.set_shuffle_mode

Sets the shuffle mode of the music player.

music.set_repeat_mode

Sets the repeat mode of the music player.

music.playback_state

The current playback state of the music player.

Now playing item

music.now_playing_item

The currently-playing media item, or the media item, within a queue, that you have designated to begin playback with.

music.index_of_now_playing_item

The index of the now playing item in the current playback queue.

Picking music

music.pick_music

Picks music with a UI.

Classes

music.MediaItem

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

music.MediaItem.album_artist

The primary performing artist for an album as a whole.

music.MediaItem.album_artist_persistent_id

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

music.MediaItem.album_persistent_id

The persistent identifier for an album.

music.MediaItem.album_title

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)”.

music.MediaItem.album_track_count

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

music.MediaItem.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.

music.MediaItem.artist_persistent_id

The persistent identifier for an artist.

music.MediaItem.artwork

The artwork image for the media item.

music.MediaItem.beats_per_minute

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

music.MediaItem.bookmark_time

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

music.MediaItem.is_cloud_item

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

music.MediaItem.comments

Textual information about the media item.

music.MediaItem.is_compilation

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

music.MediaItem.composer

The musical composer for the media item.

music.MediaItem.composer_persistent_id

The persistent identifier for a composer.

music.MediaItem.date_added

The date the item was added to the library.

music.MediaItem.disc_count

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

music.MediaItem.disc_number

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

music.MediaItem.is_explicit_item

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

music.MediaItem.genre

The musical or film genre of the media item.

music.MediaItem.genre_persistent_id

The persistent identifier for a genre.

music.MediaItem.last_played_date

The date a media item was last played.

music.MediaItem.lyrics

The lyrics for the media item.

music.MediaItem.persistent_id

The persistent identifier for the media item.

music.MediaItem.play_count

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

music.MediaItem.playback_duration

The playback duration of the media item.

music.MediaItem.playback_store_id

The non-library identifier for a media item.

music.MediaItem.podcast_persistent_id

The persistent identifier for an audio podcast.

music.MediaItem.podcast_title

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”.

music.MediaItem.has_protected_asset

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

music.MediaItem.rating

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

music.MediaItem.release_date

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

music.MediaItem.skip_count

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

music.MediaItem.title

The title (or name) of the media item.

music.MediaItem.user_grouping

Grouping information for the media item.

music.MediaQuery

A query that specifies a set of media items from the device’s media library by way of a filter and a grouping type.

music.MediaQuery.items

An array of media items that match the media query’s predicate.

music.MediaQuery.albums

Creates a media query that matches music items and that groups and sorts collections by album name.

music.MediaQuery.artists

Creates a media query that matches music items and that groups and sorts collections by artist name.

music.MediaQuery.songs

Creates a media query that matches music items and that groups and sorts collections by song name.

music.MediaQuery.playlists

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

music.MediaQuery.podcasts

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

music.MediaQuery.audiobook

Creates a media query that matches audio book items and that groups and sorts collections by audio book name.

music.MediaQuery.compilations

Creates a media query that matches compilation items and that groups and sorts collections by album name.

music.MediaQuery.composers

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

music.MediaQuery.genres

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

Constants

Repeat mode

music.REPEAT_MODE_DEFAULT

The user’s preferred repeat mode.

music.REPEAT_MODE_NONE

The music player will not repeat the current song or playlist.

music.REPEAT_MODE_ONE

The music player will repeat the current song.

music.REPEAT_MODE_ALL

The music player will repeat the current playlist.

music.SHUFFLE_MODE_DEFAULT

The user’s preferred shuffle mode.

music.SHUFFLE_MODE_OFF

The playlist is not shuffled.

music.SHUFFLE_MODE_SONGS

The playlist is shuffled by song.

music.SHUFFLE_MODE_ALBUMS

The playlist is shuffled by album.

music.PLAYBACK_STATE_STOPPED

The music player is stopped.

music.PLAYBACK_STATE_PLAYING

The music player is playing.

music.PLAYBACK_STATE_PAUSED

The music player is paused.

music.PLAYBACK_STATE_INTERRUPTED

The music player has been interrupted, such as by an incoming phone call.

music.PLAYBACK_STATE_SEEKING_FORWARD

The music player is seeking forward.

music.PLAYBACK_STATE_SEEKING_BACKWARD

The music player is seeking backward.

Objective-C classes

music.MPMusicPlayerController

The 'MPMusicPlayerController' class from the 'MediaPlayer' framework.

music.MPMediaItem

The 'MPMediaItem' class from the 'MediaPlayer' framework.

music.MPMediaItemCollection

The 'MPMediaItemCollection' class from the 'MediaPlayer' framework.

music.MPMediaQuery

The 'MPMusicMPMediaQueryPlayerController' class from the 'MediaPlayer' framework.