Retrieve the properties of the media in the user’s iTunes library.


The iTunes Library framework provides facilities for retrieving the properties of media items in a user’s iTunes library. This framework was designed to replace the iTunes XML file that developers query to fetch track and playlist metadata. iTunes library access is read-only.

To use this framework, create an ITLibrary object by calling the libraryWithAPIVersion class method, as shown in Listing 1. You can interrogate the instance returned to obtain its properties and the properties of its media items. For example:

Listing 1

Creating and initializing an ITLibrary

#import <iTunesLibrary/ITLibrary.h>
NSError *error = nil;
ITLibrary *library = [ITLibrary libraryWithAPIVersion:@"1.0" error:&error];
if (library)
        NSArray *playlists = library.allPlaylists; //  <- NSArray of ITLibPlaylist
        NSArray *tracks = library.allMediaItems; //  <- NSArray of ITLibMediaItem

To use the iTunes Library framework in your project, you add the iTunes Library framework (located at /Library/Frameworks/iTunesLibrary.framework) to the project. You also edit the build setting FRAMEWORK_SEARCH_PATHS to include /Library/Frameworks/iTunesLibrary.framework. The iTunes Library framework is available to users running iTunes v11.0 or above.




The ITLibAlbum class provides information about an album in the iTunes library. Each track associated with the album is represented as an ITLibMediaItem in this framework.


The ITLibArtist class represents an artist such as the performer of a song.


The ITLibArtwork class represents the artwork attached to a track (media item).


The ITLibMediaEntity class describes a media entity which can be a media item such as an audio track (see ITLibMediaItem) or a playlist (see ITLibPlaylist). Each media entity has a persistent unique ID assigned by iTunes and a set of properties.


The ITLibMediaItem class describes a media item (a track) in the iTunes library such as a song, a video, or a podcast. Like all media entities, each media item has a unique identifier and a set of properties.


The ITLibMediaItemVideoInfo class encapsulates the video information of a video media item. Video media items include TV shows, movies, video podcasts, etc.


The ITLibPlaylist class describes a playlist in the iTunes library. A playlist is a collection of media items (tracks). Playlists may be created and organized manually by the user or automatically generated by iTunes. Playlists are modeled as media entities. Each contains a unique identifier and a set of properties. Playlists may form a hierarchical structure. In those cases, the parentID property of ITLibPlaylist returns the persistent ID of the parent playlist.


A class that serves as the entry point to the iTunesLibrary framework. The properties and methods of ITLibrary may be used to retrieve media items (tracks) and playlists from the user’s iTunes library. ITLibrary also provides methods for extracting artwork from a media file that may or may not be in the iTunes library. This functionality is provided to sandboxed and non-sandboxed applications wanting to reuse iTunes' ability to extract artwork.