Question

I do not see any metadata on MPMediaItem that could be considered to be a globally unique identifier (in other words, the same piece of media would have the same, unique combination of values across multiple devices and user accounts). Is there a recommended metadatum that could be used in this way (or a compound set of metadata)?

Was it helpful?

Solution

All MPMediaItems and some other MediaPlayer.framework classes have a unique identifier called a persistent ID. It is a uint64_t wrapped in an NSNumber. Here are the persistent IDs you can retrieve from an MPMediaItem using valueForProperty:

NSString *const MPMediaItemPropertyPersistentID;            // filterable
NSString *const MPMediaItemPropertyAlbumPersistentID;       // filterable
NSString *const MPMediaItemPropertyArtistPersistentID;      // filterable
NSString *const MPMediaItemPropertyAlbumArtistPersistentID; // filterable
NSString *const MPMediaItemPropertyGenrePersistentID;       // filterable
NSString *const MPMediaItemPropertyComposerPersistentID;    // filterable
NSString *const MPMediaItemPropertyPodcastPersistentID;     // filterable
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top