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

# addItem(withProductID:completionHandler:)

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

```
func addItem(withProductID productID: String, completionHandler: (@Sendable ([MPMediaEntity], (any Error)?) -> Void)? = nil)
```

## Parameters

`productID`

The product identifier for the media item to add.

`completionHandler`

A block that the system calls after it plays the media item.

- entities: An array containing the media items added to the user’s music library.
- error: If an error occurred, this parameter holds the error object that explains the error. Otherwise, the value of this parameter is `nil`.

## Discussion

Use this method to add media items to a user’s music library. Use the [Apple Music API Reference](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/AppleMusicWebServicesReference/index.html#//apple_ref/doc/uid/TP40017625) to search for content contained in the iTunes, App, Book, and Mac App stores.

> Note:
> This method only works for 64-bit apps.

---

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)