fix: not showing video ads in pip mode
This commit is contained in:
parent
3f48c64364
commit
59236c7034
@ -5,14 +5,16 @@ import GoogleInteractiveMediaAds
|
|||||||
class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
|
class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
|
||||||
|
|
||||||
private weak var _video: RCTVideo?
|
private weak var _video: RCTVideo?
|
||||||
|
private var _pipEnabled:() -> Bool
|
||||||
|
|
||||||
/* Entry point for the SDK. Used to make ad requests. */
|
/* Entry point for the SDK. Used to make ad requests. */
|
||||||
private var adsLoader: IMAAdsLoader!
|
private var adsLoader: IMAAdsLoader!
|
||||||
/* Main point of interaction with the SDK. Created by the SDK as the result of an ad request. */
|
/* Main point of interaction with the SDK. Created by the SDK as the result of an ad request. */
|
||||||
private var adsManager: IMAAdsManager!
|
private var adsManager: IMAAdsManager!
|
||||||
|
|
||||||
init(video:RCTVideo!) {
|
init(video:RCTVideo!, pipEnabled:@escaping () -> Bool) {
|
||||||
_video = video
|
_video = video
|
||||||
|
_pipEnabled = pipEnabled
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
@ -86,6 +88,9 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
|
|||||||
}
|
}
|
||||||
// Play each ad once it has been loaded
|
// Play each ad once it has been loaded
|
||||||
if event.type == IMAAdEventType.LOADED {
|
if event.type == IMAAdEventType.LOADED {
|
||||||
|
if (_pipEnabled()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
adsManager.start()
|
adsManager.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
private var _filterName:String!
|
private var _filterName:String!
|
||||||
private var _filterEnabled:Bool = false
|
private var _filterEnabled:Bool = false
|
||||||
private var _presentingViewController:UIViewController?
|
private var _presentingViewController:UIViewController?
|
||||||
|
private var _pictureInPictureEnabled = false
|
||||||
|
|
||||||
/* IMA Ads */
|
/* IMA Ads */
|
||||||
private var _adTagUrl:String?
|
private var _adTagUrl:String?
|
||||||
@ -120,10 +121,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
onPictureInPictureStatusChanged?([ "isActive": NSNumber(value: false)])
|
onPictureInPictureStatusChanged?([ "isActive": NSNumber(value: false)])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isPipEnabled () -> Bool {
|
||||||
|
return _pictureInPictureEnabled
|
||||||
|
}
|
||||||
|
|
||||||
init(eventDispatcher:RCTEventDispatcher!) {
|
init(eventDispatcher:RCTEventDispatcher!) {
|
||||||
super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
||||||
#if USE_GOOGLE_IMA
|
#if USE_GOOGLE_IMA
|
||||||
_imaAdsManager = RCTIMAAdsManager(video: self)
|
_imaAdsManager = RCTIMAAdsManager(video: self, pipEnabled: isPipEnabled)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_eventDispatcher = eventDispatcher
|
_eventDispatcher = eventDispatcher
|
||||||
@ -168,7 +173,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder aDecoder: NSCoder) {
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
#if USE_GOOGLE_IMA
|
#if USE_GOOGLE_IMA
|
||||||
_imaAdsManager = RCTIMAAdsManager(video: self)
|
_imaAdsManager = RCTIMAAdsManager(video: self, pipEnabled: isPipEnabled)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,6 +464,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
try audioSession.setActive(true, options: [])
|
try audioSession.setActive(true, options: [])
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
|
if (pictureInPicture) {
|
||||||
|
_pictureInPictureEnabled = true
|
||||||
|
} else {
|
||||||
|
_pictureInPictureEnabled = false
|
||||||
|
}
|
||||||
_pip?.setPictureInPicture(pictureInPicture)
|
_pip?.setPictureInPicture(pictureInPicture)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user