It occurred to me that the AsyncIterator we get via allMetrics() might simply not produce any items.
I added an extra diagnostic message just after the for-loop in the above code, and that message is also never displayed - so it seems like the iterator does wait indefinitely for metrics to be produced, as I was expecting.
let playerItem: AVPlayerItem = ...
let allMetrics = playerItem.allMetrics()
Task.init {
print("metrics task started") // appears in output
do {
for try await metricEvent in allMetrics {
print("metric event: \(metricEvent.description)"). // does not appear
}
print("metrics task done") // also does not appear
} catch {
print("unexpected metric iterator error \(error)")
}
}
Don't know what to try next to get access to this data.