AVPlayerItemFailedToPlayToEndTime deprecated

Hello, I'm getting a "deprecated" notice for AVPlayerItemFailedToPlayToEndTime in:

https://developer.apple.com/documentation/foundation/nsnotification/name/4108587-avplayeritemfailedtoplaytoendtim

How should I use this event on SwiftUI and Swift 5?

All tutorials and forums around this question use:

let videoEnded = NotificationCenter.default.publisher(for: NSNotification.Name.AVPlayerItemDidPlayToEndTime)
/// … ContentView …
AVPlayerControllerRepresented(player: player)
  .onReceive(){ _in 
    updateTaskId
  }

Also DispatchQueue is everywhere when on should be using

.task(id){}

Could someone help out people with documentation challenges like me grok a simple example?

Thank you!

Full example and typo fix, sorry:

import SwiftUI
import AVKit

struct ContentView: View {
    @State var player = AVQueuePlayer()
    @State private var trackOnEnd = 0  

    let videoEnded = NotificationCenter.default.publisher(for: NSNotification.Name.AVPlayerItemDidPlayToEndTime)

    var body: some View {
        AVPlayerControllerRepresented(player: player)
            .onReceive(videoEnded){ _in 
                trackOnEnd = trackOnEnd + 1
            }
            .task(id: trackOnEnd){
                await insertAVPlayerItemStartPlaybackEtc()
            }
    }
}

🙏

simply change NSNotification.Name.AVPlayerItemDidPlayToEndTime to AVPlayerItem.didPlayToEndTimeNotification

AVPlayerItemFailedToPlayToEndTime deprecated
 
 
Q