YTSwiftyPlayer can't be released
Closed this issue · 1 comments
fordringd2008 commented
let player = YTSwiftyPlayer(
frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: playHeight),
playerVars: [.playsInline(true), .videoID(self.videoID), .loopVideo(true), .showRelatedVideo(false)])
player.autoplay = true
self.view.addSubview(player)
player.loadPlayer()
player.snp.makeConstraints { (make) in
make.centerX.equalTo(self.view)
make.centerY.equalTo(self.view).offset(-NavBarHeight / 2.0)
make.width.equalTo(ScreenWidth)
make.height.equalTo(playHeight)
}
self.playerT = player
rinov commented
It's not clear from the code snippet how YTSwiftyPlayer is referencing self. If you're implementing YTSwiftyPlayerDelegate and referencing self within it, you should make that reference weak. For example:
player.delegate = self // This could be causing the issue
// Modify it like this
weak var weakSelf = self
player.delegate = weakSelf
Also, if playerT is a strong reference in self.playerT = player, a similar issue can occur. You should make playerT a weak reference, or assign nil to it at an appropriate timing to release the reference.