Questions tagged [mpmediaitemcollection]

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.

A media item collection is a sorted set of media items (instances of the 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.

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.

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

External Resources

71 questions
13
votes
0 answers

how to resolve when MPMediaItem assetURL is nil?

I'm working on code that looks at the user's videos and passes them along to AVPlayer by way of an AVPlayerItem which takes a URL. To get all the videos on an iOS device, you can do: let videoNumber = MPMediaType.anyVideo.rawValue let predicate =…
8
votes
1 answer

How to get Artist picture from MPMediaItem?

I'm searching for a way to get the picture of an Artist through the MediaPlayer library. I've searched in the Apple's Doc, but there is nothing about that. The property "Artwork" refers to the album's cover. Any idea if and how i can get that ?
6
votes
2 answers

Way to persist MPMediaItemCollection objects? (selected from iPod)

I am making an app in which the user can select a song in a settings tab and have this played in a different view on demand. I want it so that this item can be stored if the user is to shut the app and reopen it another time. I have managed to allow…
Adam Waite
  • 19,175
  • 22
  • 126
  • 148
6
votes
0 answers

iOS Music Library: How to tell if a given Playlist is a folder

Say I have an iOS music library with this playlist structure: A Folder | ---> A Playlist | ---> Song A I run the following code: import MediaPlayer let playlists = MPMediaQuery.playlists().collections! as! [MPMediaPlaylist] for playlist…
Dov
  • 15,530
  • 13
  • 76
  • 177
5
votes
1 answer

Persist a MPMediaItemCollection Object Using NSUserDefaults

How do you persist a MPMediaItemCollection object using NSUserDefaults? The MPMediaItemCollection object is a single song selected from the iPod. I have been struggling with this for hours! Anyone have any ideas or alternatives to NSUserDefaults or…
Adam Waite
  • 19,175
  • 22
  • 126
  • 148
5
votes
1 answer

Play Song at specific index of MPMediaItemCollection in Swift

I try to make my own Musicplayer with Swift. I need to jump to a specific song/index of my MPMediaItemCollection and start to play it but i can only find methods like skipToNextItem() and skipToPreviousItem(). Is there any other way to do that than…
5
votes
1 answer

How do I clear the queue of a MPMusicPlayerController?

I'm trying to replicate the clear queue functionality of the iPod application, however I can't create an empty MPMediaItemCollection with which to call setQueueWithItemCollection: e.g. [self.musicPlayer…
CVertex
  • 17,997
  • 28
  • 94
  • 124
5
votes
6 answers

Number of Albums By Artists

That's my Question =) MPMediaQuery *artistQuery = [MPMediaQuery artistsQuery]; NSArray *songsByArtist = [artistQuery collections]; How can I get the number of albums of each artists of the MPMediaItemCollections in songsByArtist ? Exemple : The…
Jonathan
  • 873
  • 3
  • 9
  • 23
4
votes
2 answers

Best Practices for persisting iPod Playlist (MPMediaItemCollection) across sessions

When using in-app audio in the iPhone SDK, it is possible to allow users to select a list from their ipod library and create an in-app local playlist. If I want to persist this choice, it is easy to serialize the data and write to file, then…
coneybeare
  • 33,113
  • 21
  • 131
  • 183
4
votes
2 answers

How Do You Obtain the "Purchase Date" or "Date Added" from MPMediaItems in iPod Library

As users download new songs into their iPod Music library from the iTunes Store, I would like to programmatically list those songs in a table view. Is it possible to obtain the "Date Added" or "Purchase Date" from the MPMediaItemCollection? I see…
JeffB6688
  • 3,782
  • 5
  • 38
  • 58
3
votes
2 answers

iTunes Match + AVplayer + MPMediaQuery not working

I'm developing an app which makes usage of AVPlayer, MPMediaItem and MPMediaQuery. It works as long as Itunes match. We start with a MPMediaQuery, then we perform some filtering leaving some MPMediaItems, then we have been using AVPlayer because: …
3
votes
1 answer

How to get artwork from MPMediaItemCollection

My goal is to get the cover picture for the playlists in iPod library. And I did something like playlistMediaItemCollections = MPMediaQuery.playlistsQuery().collections ?? [] let artworks = playlistMediaItemCollections.map {…
3
votes
1 answer

Finding a Song from Persistent ID using Swift 2 programming

I am a beginner with Swift programming who is trying to re-write code that I found online that Finds A Song from Persistent ID. The original code is found at this…
3
votes
1 answer

Brief stop/start of Now Playing item when updating a media collection queue MPMediaItemCollection

Im playing about with apples addMusic sample app in xcode, as im looking to be able to add similar functionality (playing a queue of music selected by the user in the background of the app). It does this annoying thing where the music player briefly…
user1736431
  • 81
  • 1
  • 5
3
votes
1 answer

How to play songs (only songs) from a playlist on iOS?

I'm trying to play songs from an iPod playlist. As far as playlist may have videos too, I want to play only songs in them. MPMusicPlayerController *mp = [MPMusicPlayerController applicationMusicPlayer]; MPMediaQuery *query = [MPMediaQuery…
OtoLeo
  • 363
  • 3
  • 19
1
2 3 4 5