---
title: MPMediaLibrary
framework: mediaplayer
role: symbol
role_heading: Class
path: mediaplayer/mpmedialibrary
---

# MPMediaLibrary

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

## Declaration

```swift
class MPMediaLibrary
```

## Overview

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 and MPMediaQuery.

## Topics

### Getting the default media library

- [requestAuthorization(_:)](mediaplayer/mpmedialibrary/requestauthorization(_:).md)
- [authorizationStatus()](mediaplayer/mpmedialibrary/authorizationstatus().md)
- [MPMediaLibraryAuthorizationStatus](mediaplayer/mpmedialibraryauthorizationstatus.md)
- [default()](mediaplayer/mpmedialibrary/default().md)

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

- [beginGeneratingLibraryChangeNotifications()](mediaplayer/mpmedialibrary/begingeneratinglibrarychangenotifications().md)
- [endGeneratingLibraryChangeNotifications()](mediaplayer/mpmedialibrary/endgeneratinglibrarychangenotifications().md)
- [lastModifiedDate](mediaplayer/mpmedialibrary/lastmodifieddate.md)

### Retrieving a playlist from the media library

- [getPlaylist(with:creationMetadata:completionHandler:)](mediaplayer/mpmedialibrary/getplaylist(with:creationmetadata:completionhandler:).md)

### Adding an item to the media library

- [addItem(withProductID:completionHandler:)](mediaplayer/mpmedialibrary/additem(withproductid:completionhandler:).md)

### Initializers

- [init(coder:)](mediaplayer/mpmedialibrary/init(coder:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
