From 9519c7bae76486e41b6ab2cf31afa3b8280448dd Mon Sep 17 00:00:00 2001 From: Francesco Benigno Date: Tue, 28 Mar 2023 13:14:48 +0200 Subject: [PATCH] set the ad volume to 0 when the player is muted on iOS --- ios/Video/Features/RCTIMAAdsManager.swift | 4 ++++ ios/Video/RCTVideo.swift | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ios/Video/Features/RCTIMAAdsManager.swift b/ios/Video/Features/RCTIMAAdsManager.swift index 059ec639..21884857 100644 --- a/ios/Video/Features/RCTIMAAdsManager.swift +++ b/ios/Video/Features/RCTIMAAdsManager.swift @@ -76,6 +76,10 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate { // MARK: - IMAAdsManagerDelegate func adsManager(_ adsManager: IMAAdsManager, didReceive event: IMAAdEvent) { + // Mute ad if the main player is muted + if (_video.isMuted()) { + adsManager.volume = 0; + } // Play each ad once it has been loaded if event.type == IMAAdEventType.LOADED { adsManager.start() diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index be1c0981..cc0df2c6 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -496,6 +496,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH applyModifiers() } + @objc + func isMuted() -> Bool { + return _muted + } + @objc func setMuted(_ muted:Bool) { _muted = muted