Reputation: 45
I'm trying to get AVPlayer timedMetadata but the observer is never being called
self.metaItem!.addObserver(self, forKeyPath: "metaData", options: NSKeyValueObservingOptions(), context: nil)
metPlayer=AVPlayer(playerItem: metaItem)
metPlayer.play()
...
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change:
[NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath != "metaData" { return }
print("...")
}
but MPMoviePlayerController works fine
thanks.
Upvotes: 0
Views: 587
Reputation: 31685
metaItem
AVPlayerItem should observe for key path timedMetadata, but not "metaData":
self.metaItem!.addObserver(self, forKeyPath: "timedMetadata", options: NSKeyValueObservingOptions(), context: nil)
Upvotes: 1