---
title: "add(_:completionHandler:)"
framework: mediaplayer
role: symbol
role_heading: Instance Method
path: "mediaplayer/mpmediaplaylist/add(_:completionhandler:)"
---

# add(_:completionHandler:)

Adds an array of media items to the end of the playlist.

## Declaration

```swift
func add(_ mediaItems: [MPMediaItem], completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

```swift
func add(_ mediaItems: [MPMediaItem]) async throws
```

## Parameters

- `mediaItems`: The array of media items to add to the end of the playlist.
- `completionHandler`: A block that the system calls after it adds the media items to the playlist.

## See Also

### Adding media items to a playlist

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