[AirPlay] AVPlayerItemMetadataCollector doesn't report ad breaks

Hey,
I'm writing an app with the possibility to play HLS streams.
Some HLS streams I have to play have ad-breaks and I have to display them on the custom view progress bar. To do so I create an instance of AVPlayerItemMetadataCollector and add it to AVPlayerItem instance:
Code Block swift
        let asset = AVURLAsset(url: url)
        let item = AVPlayerItem(asset: asset)
        let metadataCollector = AVPlayerItemMetadataCollector()
        item.add(metadataCollector)

It works as expected when I play the stream on the device. When the player receives the manifest with EXT-X-DATERANGE tags the metadataCollector reports the ad-breaks via its delegate's metadataCollector( , didCollect: , indexesOfNewGroups: , indexesOfModifiedGroups: ) method.
But suppose, I've started a playback, switched to AirPlay, and closed the player on the device. In this case, the AirPlay device stays connected, so that if I start the playback again (the same item or another), the playback will start at once on AirPlay.
The issue in this case is:
When the playback starts at once on AirPlay, the AVPlayerItemMetadataCollector instance doesn't report any ad-breaks to its delegate.

I've tested this behavior with iPhones (iOS 14.3) and Apple TV 4K (tvOS 14.4) and LG TV with AirPlay 2 support.

Is something wrong with AVPlayerItemMetadataCollector configuration or is it an expected behavior or an iOS bug?

@elizarovkonst did you figure out a solution? I'm facing the same issue.

[AirPlay] AVPlayerItemMetadataCollector doesn't report ad breaks
 
 
Q