Instance Method

performQueueTransaction:completionHandler:

Changes the contents of the media items in the queue.

Declaration

- (void)performQueueTransaction:(void (^)(MPMusicPlayerControllerMutableQueue *queue))queueTransaction completionHandler:(void (^)(MPMusicPlayerControllerQueue *queue, NSError *error))completionHandler;

Parameters

queueTransaction

A block that is called while the queue is created.

queue

The queue that is being modified.

completionHandler

A block that is called after the user has accepted the new queue.

queue

The newly modified queue that was accepted by the user.

error

If an error occurred, this parameter holds the error object that explains the error. Otherwise, the value of this parameter is nil.

Discussion

Perform all of your queue modifications inside of the queue transition block. After the queue inside of the queue transition block has been modified, the new queue is returned from the completion handler after the user has accepted the new queue. Do not 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

MPMusicPlayerControllerQueueDidChangeNotification

Indicates the music player's queue changed.