fix(ios): destroy adsManager when player detach from super view (#3716) (#3722)

* fix(ios): destroy adsManager when player detach from super view (#3716)

* fix: swift format
This commit is contained in:
Nguyễn Bảo Khương 2024-05-01 16:31:20 +07:00 committed by GitHub
parent ecc946d1c1
commit e96c17321f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -44,6 +44,16 @@
}
}
func releaseAds() {
guard let adsManager else { return }
// Destroy AdsManager may be delayed for a few milliseconds
// But what we want is it stopped producing sound immediately
// Issue found on tvOS 17, or iOS if view detach & STARTED event happen at the same moment
adsManager.volume = 0
adsManager.pause()
adsManager.destroy()
}
// MARK: - Getters
func getAdsLoader() -> IMAAdsLoader? {

View File

@ -1187,6 +1187,10 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
_resouceLoaderDelegate = nil
_playerObserver.clearPlayer()
#if USE_GOOGLE_IMA
_imaAdsManager.releaseAds()
#endif
self.removePlayerLayer()
if let _playerViewController {