I am would like to look at AVMetricEvent data during video playback, so I have added this code to a test video player app:
let playerItem: AVPlayerItem = ... let allMetrics = playerItem.allMetrics() Task.init { print("metrics task started") do { for try await metricEvent in allMetrics { print("metric event: \(metricEvent.description)") } } catch { print("unexpected metric iterator error \(error)") } }
Running this in Simulator on iPhone 16 Pro (18.0) does not result in any "metric event
" diagnostic messages being printed when the video associated with this AVPlayerItem
is playing. Only the "metric task started
" diagnostic message is seen.
What am I doing wrong that prevents metric data being received?