---
title: "perform(queueTransaction:completionHandler:)"
framework: mediaplayer
role: symbol
role_heading: Instance Method
path: "mediaplayer/mpmusicplayerapplicationcontroller/perform(queuetransaction:completionhandler:)"
---

# perform(queueTransaction:completionHandler:)

Changes the contents of the media items in the queue.

## Declaration

```swift
func perform(queueTransaction: @escaping (MPMusicPlayerControllerMutableQueue) -> Void, completionHandler: @escaping @Sendable (MPMusicPlayerControllerQueue, (any Error)?) -> Void)
```

```swift
func perform(queueTransaction: @escaping (MPMusicPlayerControllerMutableQueue) -> Void) async throws -> MPMusicPlayerControllerQueue
```

## Parameters

- `queueTransaction`: A block that the system calls while it creates the queue.
- `completionHandler`: A block that the system calls after the user accepts the new queue.

## Discussion

Discussion Perform all of your queue modifications inside of the queue transition block. After the system modifies the queue inside of the queue transition block, it returns the new queue from the completion handler after the user accepts the new queue. Don’t access the completion handler’s queue outside of the completion handler. If you modify the queue outside of the completion handler, register for the MPMusicPlayerControllerQueueDidChangeNotification notification and ensure your app responds accordingly.

## See Also

### Changing the queue contents

- [MPMusicPlayerControllerQueueDidChange](foundation/nsnotification/name-swift.struct/mpmusicplayercontrollerqueuedidchange.md)
