---
title: "addItem(withProductID:completionHandler:)"
framework: mediaplayer
role: symbol
role_heading: Instance Method
path: "mediaplayer/mpmedialibrary/additem(withproductid:completionhandler:)"
---

# addItem(withProductID:completionHandler:)

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

## Declaration

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

```swift
func addItem(withProductID productID: String) async throws -> [MPMediaEntity]
```

## Parameters

- `productID`: The product identifier for the media item to add.
- `completionHandler`: A block that the system calls after it plays the media item.

## Discussion

Discussion Use this method to add media items to a user’s music library. Use the Apple Music API Reference to search for content contained in the iTunes, App, Book, and Mac App stores. note: This method only works for 64-bit apps.
