                 let vc = AVPlayerViewController()
                 vc.player = player
 
+                let endTimeListener = EndTimeListener(media: media, playerViewController: vc, playerItem: item)
+                item.userInfo = endTimeListener // Give it the same lifetime as the item.
+
                 presenter.present(vc, animated: true, completion: { [weak vc] in
                     vc?.player?.play()
                 })

        })
    }
}

            DispatchQueue.main.async {
                UIApplication.shared.endIgnoringInteractionEvents()
                
                let item = PlayerItemWithUserInfo(url: url)
                let player = AVPlayer(playerItem: item)
                let interval = CMTime(seconds: 10, preferredTimescale: CMTimeScale(NSEC_PER_SEC))
                player.addPeriodicTimeObserver(forInterval: interval, queue: DispatchQueue.main, using: { (time: CMTime) in
                    SetBookmarkService.postBookmark(item: media, time: Int(time.seconds))
