iOS Developer Library

Developer

MediaPlayer Framework Reference MPMediaLibrary Class Reference

Options
Deployment Target:

On This Page
Language:

MPMediaLibrary

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.

Inheritance


Import Statement


Swift

import MediaPlayer

Objective-C

@import MediaPlayer;

Availability


Available in iOS 3.0 and later.
  • Gets an instance of the default media library.

    Declaration

    Swift

    class func defaultMediaLibrary() -> MPMediaLibrary!

    Objective-C

    + (MPMediaLibrary *)defaultMediaLibrary

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.

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

    Declaration

    Swift

    var lastModifiedDate: NSDate! { get }

    Objective-C

    @property(nonatomic, readonly) NSDate *lastModifiedDate

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.

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

    Declaration

    Swift

    func beginGeneratingLibraryChangeNotifications()

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.

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

    Declaration

    Swift

    func endGeneratingLibraryChangeNotifications()

    Objective-C

    - (void)endGeneratingLibraryChangeNotifications

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 3.0 and later.