i​Tunes​Library

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

Overview

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 library​With​APIVersion 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/i​Tunes​Library.framework) to the project. You also edit the build setting FRAMEWORK_SEARCH_PATHS to include /Library/Frameworks/i​Tunes​Library.framework. The iTunes Library framework is available to users running iTunes v11.0 or above.

Symbols

Classes

ITLib​Album

The ITLib​Album class provides information about an album in the iTunes library. Each track associated with the album is represented as an ITLib​Media​Item in this framework.

ITLib​Artist

The ITLib​Artist class represents an artist such as the performer of a song.

ITLib​Artwork

The ITLib​Artwork class represents the artwork attached to a track (media item).

ITLib​Media​Entity

The ITLib​Media​Entity class describes a media entity which can be a media item such as an audio track (see ITLib​Media​Item) or a playlist (see ITLib​Playlist). Each media entity has a persistent unique ID assigned by iTunes and a set of properties.

ITLib​Media​Item

The ITLib​Media​Item 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.

ITLib​Media​Item​Video​Info

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

ITLib​Playlist

The ITLib​Playlist 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 parent​ID property of ITLib​Playlist returns the persistent ID of the parent playlist.

ITLibrary

The ITLibrary class 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 re-use iTunes' ability to extract artwork.