youtube / youtube-ios-player-helper

Lightweight helper library that allows iOS developers to add inline playback of YouTube videos through a WebView
Other
1.64k stars 677 forks source link

Memory leak issue when calling StopViedo() #511

Open gogochang opened 6 months ago

gogochang commented 6 months ago

Calling the stopViedo() method causes a memory leak. I only used events on the UI button

class ViewController: UIViewController {
    private var ytPlayer: YTPlayerView
    private let stop = UIButton()

    init(ytPlayer: YTPlayerView = YTPlayerView()) {
        self.ytPlayer = ytPlayer    
        super.init(nibName: nil, bundle: nil)
        self.ytPlayer.load(
            withVideoId: "VideoID",
            playerVars: [
                "autoplay": 0,
                "playsinline" : 1,
                "cc_load_policy" : 1,
                "loop" : 1,
                "playlist" : "VideoID",
                "fs": 0])

        stop.addTarget(self, action: #selector(test), for: .touchUpInside)

    }

    @objc func test() {
        ytPlayer.stopVideo()
    }

}

How do you solve this issue?

스크린샷 2024-02-01 오전 10 26 18