I'm running into this same problem when trying to observe values from the KVO-compliant timeControlStatus property on AVPlayer:
init() {
self.player = AVPlayer()
Task { [weak self] in
guard let self else { return }
// Observe changes to timeControlStatus using Combine on the AVPlayer
for await newValue in player.publisher(for: \.timeControlStatus).values {
isPlaying = newValue == .playing // this only gets called for the initial value and never again, the loop does not exit
}
}
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: