我正在尝试获取AVPlayer timedMetadata,但永远不会调用观察者
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("...")
}
但MPMoviePlayerController工作正常
感谢。
答案 0 :(得分:1)
metaItem
AVPlayerItem应该观察关键路径 timedMetadata ,但不是" metaData" :
self.metaItem!.addObserver(self, forKeyPath: "timedMetadata", options: NSKeyValueObservingOptions(), context: nil)