Async publisher for AVPlayerItem.tracks doesn't produce values.

I'm just putting this here for visibility, I already submitted FB13688825.

If you say this:

Task {
    for await tracks in avPlayerItem.publisher(for: \.tracks, options: [.initial]).values {
        print("*** fired with: \(tracks.description)")
    }
}

...it fires once with: "*** fired with: []"

If you say this:

avPlayerItem.publisher(for: \.tracks).sink { [weak self] tracks in
    print("*** fired with: \(tracks.description)")
}.store(in: &subscriptions)

...you get, as expected, multiple fires, most with data in them such as: *** fired with: [<AVPlayerItemTrack: 0x10a9869a0, assetTrack = <AVAssetTrack: 0x10a9869f0...

I think it's a bug but I'm just going to go back to the "old way" for now. No emergency.

You have to keep a strong reference to the Task.

Adding a .buffer before .values was the answer. Thanks for reading!

Async publisher for AVPlayerItem.tracks doesn't produce values.
 
 
Q