---
title: "requestMediaDataWhenReady(on:using:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avqueuedsamplebufferrendering/requestmediadatawhenready(on:using:)"
---

# requestMediaDataWhenReady(on:using:)

Tells the target to invoke a client-supplied block in order to gather sample buffers for playback.

## Declaration

```swift
func requestMediaDataWhenReady(on queue: dispatch_queue_t, using block: @escaping @Sendable () -> Void)
```

## Parameters

- `queue`: The dispatch queue.
- `block`: A block that enqueues sample buffers until the receiver is no longer ready or there is no more data to supply.

## Discussion

Discussion When this method is called multiple times, only the last call is implemented. Pair each call to requestMediaDataWhenReady(on:using:) with a corresponding call to stopRequestingMediaData(). Releasing the AVQueuedSampleBufferRendering object without a call to stopRequestingMediaData results in undefined behavior.

## See Also

### Requesting media

- [isReadyForMoreMediaData](avfoundation/avqueuedsamplebufferrendering/isreadyformoremediadata.md)
- [enqueue(_:)](avfoundation/avqueuedsamplebufferrendering/enqueue(_:).md)
- [stopRequestingMediaData()](avfoundation/avqueuedsamplebufferrendering/stoprequestingmediadata().md)
