Ios receives a game account for items in the media library

Currently, I am trying to classify the music collection of users and the ability to receive the most popular songs / artists that will significantly improve the user experience in the application. Can I get a song counter? and how will I do it

+7
source share
3 answers

MPMediaItem has a method:

- (id) valueForProperty: (NSString *) property 

This method returns the key of the media property to which you want to get the corresponding value. And one of the feature values ​​is MPMediaItemPropertyPlayCount:

The number of times a user played a multimedia item. Value is an NSNumber object representing the NSUInteger data type.

Here you can check the doc here and here .

+8
source

If you want to find the most played tracks of the user, you can:

  • Save all media elements (ie [[MPMediaQuery songsQuery] items] ) and their properties in the database (for example, master data), select their NSFetchRequest and sort the results using NSSortDescriptor .

  • ... or use [[MPMediaQuery songsQuery] items] and sort the results in the MPMediaItemPropertyPlayCount property.

Option (1) is probably best, especially if you want to classify a music collection (I believe that (2) could be worse in performance).

There's also a similar answer to SO to answer your question.

Check out Apple docs for more information on MPMediaQueries.

+3
source

If you use Core Data, you have many methods for you. Check this out: http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/CoreData/cdProgrammingGuide.html

+1
source

All Articles