gpt4 book ai didi

swift - AVPlayer addObserver 永远不会被调用

转载 作者:行者123 更新时间:2023-11-28 15:55:13 25 4
gpt4 key购买 nike

我正在尝试获取 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 工作正常

谢谢。

最佳答案

metaItem AVPlayerItem 应该观察关键路径 timedMetadata ,但不是“元数据”:

self.metaItem!.addObserver(self, forKeyPath: "timedMetadata", options: NSKeyValueObservingOptions(), context: nil)

关于swift - AVPlayer addObserver 永远不会被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41871838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com