You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should this didSet have an unregisterNotifications for when you set nil maybe?
I'm running into a problem where I incessantly have onVideoFinished called every time reset and play a video.
func play(){
if let player = videoView.playerLayer.player{
player.play()}else{// First run
videoView.isLooping = configuration?.shouldLoop ?? videoView.isLooping
videoView.onVideoFinished ={print("onVideoFinished")}
videoView.play()}
Every time I close and open/play, I get progressively more logs of onVideoFinished
The text was updated successfully, but these errors were encountered:
As an example, I just scrolled through a handful of videos in a collection view, and when I played my next video, I had about 50 onVideoFinished queued up and printed 🤯
I'm sure this has to do with my views being cached, but I'm also wiping out the handler during cleanup, so it's all strange 😆
Note: I don't have a full fix yet, but as a quick workaround, I'm manually calling NotificationCenter.default.removeObserver(videoView) after I reset the videoView, and also when I'm doing any cleanup in prepareForReuse or elsewhere.
That has mitigated the problem for the most part today. Will come back to this when I get to re-factor that part of my code in the next few months.
I noticed that
registerNotifications
is called every time theplayer
is set, which happens both onplay
and onreset
.Should this didSet have an unregisterNotifications for when you set
nil
maybe?I'm running into a problem where I incessantly have
onVideoFinished
called every time reset and play a video.Every time I close and open/play, I get progressively more logs of
onVideoFinished
The text was updated successfully, but these errors were encountered: