<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMediaLibrary",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMediaLibrary"
  },
  "title" : "MPMediaLibrary"
}
-->

# MPMediaLibrary

An object that represents the state of synced media items on a device.

```
class MPMediaLibrary
```

## Overview

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

To retrieve media items from the media library, build a custom query as described in [`MPMediaPropertyPredicate`](/documentation/MediaPlayer/MPMediaPropertyPredicate) and [`MPMediaQuery`](/documentation/MediaPlayer/MPMediaQuery).

## Topics

### Getting the default media library

[`+  requestAuthorization:`](/documentation/MediaPlayer/MPMediaLibrary/requestAuthorization(_:))

Displays a user interface so that the user can authorize whether your app may view the media library’s contents.

[`+  authorizationStatus`](/documentation/MediaPlayer/MPMediaLibrary/authorizationStatus())

Returns whether the app can access the user’s media library.

[`MPMediaLibraryAuthorizationStatus`](/documentation/MediaPlayer/MPMediaLibraryAuthorizationStatus)

The list of possible states for authorization to access to the user’s media library.

[`+  defaultMediaLibrary`](/documentation/MediaPlayer/MPMediaLibrary/default())

Returns an instance of the default media library.

### Receiving notifications when the user’s library changes

[`-  beginGeneratingLibraryChangeNotifications`](/documentation/MediaPlayer/MPMediaLibrary/beginGeneratingLibraryChangeNotifications())

Asks the media library to turn on notifications for whenever the library changes.

[`-  endGeneratingLibraryChangeNotifications`](/documentation/MediaPlayer/MPMediaLibrary/endGeneratingLibraryChangeNotifications())

Asks the media library to turn off notifications for whenever the library changes.

[`MPMediaLibraryDidChangeNotification`](/documentation/MediaPlayer/MPMediaLibraryDidChangeNotification)

Indicates the media library has changed.

[`lastModifiedDate`](/documentation/MediaPlayer/MPMediaLibrary/lastModifiedDate)

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

### Retrieving a playlist from the media library

[`-  getPlaylistWithUUID:creationMetadata:completionHandler:`](/documentation/MediaPlayer/MPMediaLibrary/getPlaylist(with:creationMetadata:completionHandler:))

Retrieves an app maintained existing playlist or creates a new playlist when no playlist exists.

### Adding an item to the media library

[`-  addItemWithProductID:completionHandler:`](/documentation/MediaPlayer/MPMediaLibrary/addItem(withProductID:completionHandler:))

Adds the designated item to the user’s music library.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)