MPMediaLibrary Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/MediaPlayer.framework
Availability
Available in iOS 3.0 and later.
Companion guide
Declared in
MPMediaLibrary.h
Related sample code

Overview

An MPMediaLibrary object, or media library, represents the state of the set of synced media items (such as songs) on a device. The complete library of media items itself is called the iPod library.

A user may sync their device, changing the content of the iPod library, while your application is running. You can use the notification provided by this class to ensure that your application’s cache of the iPod library is up-to-date.

To retrieve media items from the iPod library, build a custom query as described in MPMediaPropertyPredicate Class Reference and MPMediaQuery Class Reference.

Tasks

Using the Default Media Library

Properties

lastModifiedDate

The calendar date on which a media library was last modified.

@property (nonatomic, readonly) NSDate *lastModifiedDate;
Availability
  • Available in iOS 3.0 and later.
Declared In
MPMediaLibrary.h

Class Methods

defaultMediaLibrary

Gets an instance of the default media library.

+ (MPMediaLibrary *)defaultMediaLibrary
Availability
  • Available in iOS 3.0 and later.
Related Sample Code
Declared In
MPMediaLibrary.h

Instance Methods

beginGeneratingLibraryChangeNotifications

Asks a media library to turn on notifications for device-to-computer synchronizations.

- (void)beginGeneratingLibraryChangeNotifications
Discussion

This method is nestable—that is, you can call it multiple times. To turn off notifications, you must call endGeneratingLibraryChangeNotifications the same number of times that you called beginGeneratingLibraryChangeNotifications.

Availability
  • Available in iOS 3.0 and later.
Related Sample Code
Declared In
MPMediaLibrary.h

endGeneratingLibraryChangeNotifications

Asks a media library to turn off notifications for device-to-computer synchronizations.

- (void)endGeneratingLibraryChangeNotifications
Availability
  • Available in iOS 3.0 and later.
Related Sample Code
Declared In
MPMediaLibrary.h

Notifications

MPMediaLibraryDidChangeNotification

When MPMediaLibraryDidChangeNotification is posted, your application should reevaluate items or playlists that you previously cached.
Availability
Declared In
MPMediaLibrary.h