[问题] 关于avplayer loading 问题

楼主: herbacin (herbacin)   2017-04-24 08:58:14
请问一下 最近碰到avplayer loading时机的问题, 目前想做到当在进行
缓冲的时候, 显示loading的动画
目前看到的做法是注册监听
self.playerItem?.addObserver(self, forKeyPath: "playbackBufferEmpty", options: .new, context: nil)
self.playerItem?.addObserver(self, forKeyPath: "playbackLikelyToKeepUp", options: .new, context: nil)
self.playerItem?.addObserver(self, forKeyPath: "playbackBufferFull", options: .new, context: nil)
override func observeValue()
if keyPath == "playbackBufferEmpty" {
if let item = playerItem {
if item.isPlaybackBufferEmpty {
self.download.startAnimating()
}
}
} else if keyPath == "playbackLikelyToKeepUp" {
if let item = playerItem {
if item.isPlaybackLikelyToKeepUp {
self.download.stopAnimating()
}
}
} else if keyPath == "playbackBufferFull" {
if let item = playerItem {
if item.isPlaybackBufferFull {
self.download.stopAnimating()
}
}
}
但是发现 loading 动画停止的时候 并不会 马上播放, 要等好几秒
要怎么才能做到当loading动画停止"马上"播放
作者: yuanruo (罪を憎んで人を憎まず)   2017-04-24 10:49:00
KVO回调里监听playerItem 的status
楼主: herbacin (herbacin)   2017-04-24 11:09:00
status == readyToPlay?seek后并没有回调 status

Links booklink

Contact Us: admin [ a t ] ucptt.com