andreipitis / ASPVideoPlayer

A simple video player that allow animations to be performed on the view during playback.
MIT License
89 stars 43 forks source link

Video loading reproduce in another views #24

Closed alexviquez closed 6 years ago

alexviquez commented 6 years ago

Hello, I have a problem with the player, in the case of me to load the player and leave the view after it, then the video not loading is not uninitialized, this generates that the audio of the video live in the app without I can remove it, this only happens when it is loading, I play and I leave the view without allowing to play the video.

andreipitis commented 6 years ago

Hi @alexviquez ,

There was an issue where an instance of ASPVideoPlayer would be released only after a delay of 3 seconds.

If this was your issue then it should be fixed in the latest version, however if the player never gets deallocated for you, you may have a retain cycle somewhere.

MattiaConfalonieri commented 6 years ago

Hi, i also have this bug. is it solved? I have installed via Pod.

andreipitis commented 6 years ago

Hi @MattiaConfalonieri , what version are you using? This should be fixed since version 4.0.

MattiaConfalonieri commented 6 years ago

Hi, the last one (4.2.0) with the pod...

I have a controller with the video that autoplay when read in the viewdidload. When user dismiss the controller I stop the video in the viewWillDisappea trough .stopVideo() After that close the app in the background wait 2/3 minutes and open the app, when the app return in foreground you can ear the video audio from the previous dismissed controller.

andreipitis commented 6 years ago

I have done some quick tests but I am unable to reproduce your issue. My guess is that you have a reference cycle somewhere in your code which leads to the player not deallocating properly, which in turn may cause your issue.

MattiaConfalonieri commented 6 years ago

Sorry but I can't see nothing wrong in my controller... https://pastebin.com/iHk2va2X

andreipitis commented 6 years ago

Lines 45, 48 and 53. The closures capture a strong reference to self (the view controller), and the ViewController has a reference to the player which leads to a retain cycle. Just change the closures to capture self as weak or unowned and it should fix it.

Example:

videoPlayer.readyToPlayVideo = { [weak self] in
            self?.videoPlayer.playVideo()
}

or

videoPlayer.readyToPlayVideo = { [unowned self] in
            self.videoPlayer.playVideo()
}
MattiaConfalonieri commented 6 years ago

Sorry, but nothing change... still have the bug

andreipitis commented 6 years ago

It's possible that you have other retain cycles that I missed. Is your view controller getting deallocated when dismissed? If not then there may be some other issues. If the player gets deallocated properly then there should be no way for it to play anything anymore.

MattiaConfalonieri commented 6 years ago

Thanks for help. mmmmm I think you right, maybe there is some shit in my code... thanks I looking for