-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这个播放库适合做流短视频Feed吗? #36
Comments
这个用哪一种播放控件没有区别的,如果你说的是那种全屏滚动切换视频的方式的话你得在业务侧做好Player的复用就可以了,理论上最多需要3个Player就可以了。 |
现在已经进行了AVPlayer的释放处理,比如设置为nil、移除监听通知等等,而且AVPlayer所在父控件都已经deinit了,但是内存却一直没有降下去,不知道是啥原因,请赐教。 func stop() {
//先移除观察
removePeriodicTimeObserver()
player?.isMuted = true
player?.pause()
player?.currentItem?.cancelPendingSeeks()
player?.currentItem?.asset.cancelLoading()
player?.replaceCurrentItem(with: nil)
player?.volume = 0
player = nil
playerItem?.cancelPendingSeeks()
playerItem?.asset.cancelLoading()
playerItem = nil
playerLayer?.removeFromSuperlayer()
playerLayer = nil // 释放引用
tryUnknownCount = 0
// Optionally deactivate audio session
do {
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setActive(false, options: .notifyOthersOnDeactivation)
} catch {
print("Failed to deactivate audio session: \(error)")
}
} |
释放逻辑差不多是上面的那些对象,SZAVPlayer库里面也有类似过程,可以参考这个地方 SZAVPlayer/Sources/Classes/SZAVPlayer.swift Line 217 in 4f6cf61
你可以简单改造一下DEMO里面的展示逻辑模拟你的业务逻辑看看在SZAVPlayer里面是否是能正常释放的,你也可以制造一个最小复现DEMO来辅助追踪问题点,我空的时候可以排查看看。 |
好的,谢谢。 |
目前用AVPlayer实现左右滚动Feed流,因为滚动后每加载新的界面,会实例化播放控件,内存一直逐渐增加,所以想试试你这个SZAVPlayer。还有请问下这种情况是什么原因呢?
The text was updated successfully, but these errors were encountered: