From 70c3b3be737bfa491397c4473bda3f57d6e08af0 Mon Sep 17 00:00:00 2001 From: David Somers <126989+jalada@users.noreply.github.com> Date: Mon, 6 Mar 2023 11:26:17 +0000 Subject: [PATCH 1/9] Fix typo It's `fontSize` not `fontSizeTrack` --- API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API.md b/API.md index a769aeba..d927a3b2 100644 --- a/API.md +++ b/API.md @@ -920,7 +920,7 @@ The following other types are supported on some platforms, but aren't fully docu Property | Description | Platforms --- | --- | --- -fontSizeTrack | Adjust the font size of the subtitles. Default: font size of the device | Android +fontSize | Adjust the font size of the subtitles. Default: font size of the device | Android paddingTop | Adjust the top padding of the subtitles. Default: 0| Android paddingBottom | Adjust the bottom padding of the subtitles. Default: 0| Android paddingLeft | Adjust the left padding of the subtitles. Default: 0| Android From 9baa1391ca54d321a9717514adfbae25f9984bf1 Mon Sep 17 00:00:00 2001 From: Sunbreak Date: Fri, 10 Mar 2023 10:15:02 +0800 Subject: [PATCH 2/9] fix: update debug JSBundle name & rootView component --- examples/basic/ios/videoplayer/AppDelegate.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/basic/ios/videoplayer/AppDelegate.mm b/examples/basic/ios/videoplayer/AppDelegate.mm index f06f3669..e263372b 100644 --- a/examples/basic/ios/videoplayer/AppDelegate.mm +++ b/examples/basic/ios/videoplayer/AppDelegate.mm @@ -44,7 +44,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot"; #endif NSDictionary *initProps = [self prepareInitialProps]; - UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"videoplayer", initProps); + UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"VideoPlayer", initProps); if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; @@ -85,7 +85,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot"; - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"src/index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif From 4aca30d308e33d0e6410caabd5fcafd8b996ec7a Mon Sep 17 00:00:00 2001 From: olivier Date: Sun, 12 Mar 2023 23:29:03 +0100 Subject: [PATCH 3/9] fix: disable Google IMA by default on ios. now shall be enabled in project podfile --- API.md | 11 ++++++++ examples/basic/ios/Podfile | 2 ++ ios/Video/Features/RCTIMAAdsManager.swift | 2 ++ ios/Video/RCTVideo.swift | 31 ++++++++++++++++------- react-native-video.podspec | 11 ++++++-- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/API.md b/API.md index d927a3b2..40781558 100644 --- a/API.md +++ b/API.md @@ -74,6 +74,17 @@ Video with caching ([more info](docs/caching.md)): end ``` +#### Enable custom feature in podfile file + +##### Google IMA + +Google IMA is the google SDK to support Client Side Ads Integration (CSAI), see [google documentation](https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side) for more informations. + +To enable google IMA usage define add following line in your podfile: +```podfile +$RNVideoUseGoogleIMA=true +``` + ### tvOS installation diff --git a/examples/basic/ios/Podfile b/examples/basic/ios/Podfile index 5677fd6c..9438f885 100644 --- a/examples/basic/ios/Podfile +++ b/examples/basic/ios/Podfile @@ -7,6 +7,8 @@ install! 'cocoapods', :deterministic_uuids => false target 'videoplayer' do config = use_native_modules! + # $RNVideoUseGoogleIMA = true + # Flags change depending on the env values. flags = get_default_flags() diff --git a/ios/Video/Features/RCTIMAAdsManager.swift b/ios/Video/Features/RCTIMAAdsManager.swift index 059ec639..d2a3833f 100644 --- a/ios/Video/Features/RCTIMAAdsManager.swift +++ b/ios/Video/Features/RCTIMAAdsManager.swift @@ -1,3 +1,4 @@ +#if USE_GOOGLE_IMA import Foundation import GoogleInteractiveMediaAds @@ -185,3 +186,4 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate { return result; } } +#endif diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index be1c0981..678623d4 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -1,7 +1,9 @@ import AVFoundation import AVKit import Foundation +#if USE_GOOGLE_IMA import GoogleInteractiveMediaAds +#endif import React import Promises @@ -63,11 +65,13 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH /* IMA Ads */ private var _adTagUrl:String? +#if USE_GOOGLE_IMA private var _imaAdsManager: RCTIMAAdsManager! - private var _didRequestAds:Bool = false - private var _adPlaying:Bool = false /* Playhead used by the SDK to track content video progress and insert mid-rolls. */ private var _contentPlayhead: IMAAVPlayerContentPlayhead? +#endif + private var _didRequestAds:Bool = false + private var _adPlaying:Bool = false private var _resouceLoaderDelegate: RCTResourceLoaderDelegate? private var _playerObserver: RCTPlayerObserver = RCTPlayerObserver() @@ -107,8 +111,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH init(eventDispatcher:RCTEventDispatcher!) { super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) - +#if USE_GOOGLE_IMA _imaAdsManager = RCTIMAAdsManager(video: self) +#endif _eventDispatcher = eventDispatcher @@ -147,8 +152,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - +#if USE_GOOGLE_IMA _imaAdsManager = RCTIMAAdsManager(video: self) +#endif } deinit { @@ -217,10 +223,12 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH ]) if currentTimeSecs >= 0 { +#if USE_GOOGLE_IMA if !_didRequestAds && currentTimeSecs >= 0.0001 && _adTagUrl != nil { _imaAdsManager.requestAds() _didRequestAds = true } +#endif onVideoProgress?([ "currentTime": NSNumber(value: Float(currentTimeSecs)), "playableDuration": RCTVideoUtils.calculatePlayableDuration(_player), @@ -307,13 +315,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH self.setAutomaticallyWaitsToMinimizeStalling(self._automaticallyWaitsToMinimizeStalling) } +#if USE_GOOGLE_IMA if self._adTagUrl != nil { // Set up your content playhead and contentComplete callback. self._contentPlayhead = IMAAVPlayerContentPlayhead(avPlayer: self._player!) self._imaAdsManager.setUpAdsLoader() } - +#endif //Perform on next run loop, otherwise onVideoLoadStart is nil self.onVideoLoadStart?([ "src": [ @@ -424,7 +433,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH func setPaused(_ paused:Bool) { if paused { if _adPlaying { +#if USE_GOOGLE_IMA _imaAdsManager.getAdsManager()?.pause() +#endif } else { _player?.pause() _player?.rate = 0.0 @@ -433,7 +444,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH RCTPlayerOperations.configureAudio(ignoreSilentSwitch:_ignoreSilentSwitch, mixWithOthers:_mixWithOthers) if _adPlaying { +#if USE_GOOGLE_IMA _imaAdsManager.getAdsManager()?.resume() +#endif } else { if #available(iOS 10.0, *), !_automaticallyWaitsToMinimizeStalling { _player?.playImmediately(atRate: _rate) @@ -824,11 +837,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH func setAdTagUrl(_ adTagUrl:String!) { _adTagUrl = adTagUrl } - +#if USE_GOOGLE_IMA func getContentPlayhead() -> IMAAVPlayerContentPlayhead? { return _contentPlayhead } - +#endif func setAdPlaying(_ adPlaying:Bool) { _adPlaying = adPlaying } @@ -1106,11 +1119,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH @objc func handlePlayerItemDidReachEnd(notification:NSNotification!) { onVideoEnd?(["target": reactTag as Any]) - +#if USE_GOOGLE_IMA if notification.object as? AVPlayerItem == _player?.currentItem { _imaAdsManager.getAdsLoader()?.contentComplete() } - +#endif if _repeat { let item:AVPlayerItem! = notification.object as? AVPlayerItem item.seek(to: CMTime.zero, completionHandler: nil) diff --git a/react-native-video.podspec b/react-native-video.podspec index c0c4a86a..45710b3a 100644 --- a/react-native-video.podspec +++ b/react-native-video.podspec @@ -19,8 +19,15 @@ Pod::Spec.new do |s| ss.source_files = "ios/Video/**/*.{h,m,swift}" ss.dependency "PromisesSwift" - ss.ios.dependency 'GoogleAds-IMA-iOS-SDK', '~> 3.18.1' - ss.tvos.dependency 'GoogleAds-IMA-tvOS-SDK', '~> 4.2' + if defined?($RNVideoUseGoogleIMA) + Pod::UI.puts "RNVideo: enable IMA SDK" + + ss.ios.dependency 'GoogleAds-IMA-iOS-SDK', '~> 3.18.1' + ss.tvos.dependency 'GoogleAds-IMA-tvOS-SDK', '~> 4.2' + ss.pod_target_xcconfig = { + 'OTHER_SWIFT_FLAGS' => '$(inherited) -D USE_GOOGLE_IMA' + } + end end s.subspec "VideoCaching" do |ss| From 2ef2b8eb98b96adb5f8cd645686a5ba7f8a628bc Mon Sep 17 00:00:00 2001 From: Sunbreak Date: Wed, 15 Mar 2023 00:09:31 +0800 Subject: [PATCH 4/9] fix: remove undocumented currentTime property --- CHANGELOG.md | 4 ++++ Video.js | 1 - ios/Video/RCTVideo.swift | 14 ++++---------- ios/Video/RCTVideoManager.m | 1 - 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71b54f1c..b3ad99b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### Version 6.0.0-alpha.6 + +- iOS: remove undocumented `currentTime` property [#3064](https://github.com/react-native-video/react-native-video/pull/3064) + ### Version 6.0.0-alpha.5 - iOS: ensure controls are not displayed when disabled by user [#3017](https://github.com/react-native-video/react-native-video/pull/3017) diff --git a/Video.js b/Video.js index ac6bc085..bbd7d621 100644 --- a/Video.js +++ b/Video.js @@ -520,7 +520,6 @@ Video.propTypes = { disableBuffering: PropTypes.bool, controls: PropTypes.bool, audioOnly: PropTypes.bool, - currentTime: PropTypes.number, fullscreenAutorotate: PropTypes.bool, fullscreenOrientation: PropTypes.oneOf(['all', 'landscape', 'portrait']), progressUpdateInterval: PropTypes.number, diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index be1c0981..fee5eb60 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -448,15 +448,6 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH _paused = paused } - @objc - func setCurrentTime(_ currentTime:Float) { - let info:NSDictionary = [ - "time": NSNumber(value: currentTime), - "tolerance": NSNumber(value: 100) - ] - setSeek(info) - } - @objc func setSeek(_ info:NSDictionary!) { let seekTime:NSNumber! = info["time"] as! NSNumber @@ -996,7 +987,10 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH } if _pendingSeek { - setCurrentTime(_pendingSeekTime) + setSeek([ + "time": NSNumber(value: _pendingSeekTime), + "tolerance": NSNumber(value: 100) + ]) _pendingSeek = false } diff --git a/ios/Video/RCTVideoManager.m b/ios/Video/RCTVideoManager.m index 2781656b..0d503d14 100644 --- a/ios/Video/RCTVideoManager.m +++ b/ios/Video/RCTVideoManager.m @@ -27,7 +27,6 @@ RCT_EXPORT_VIEW_PROPERTY(ignoreSilentSwitch, NSString); RCT_EXPORT_VIEW_PROPERTY(mixWithOthers, NSString); RCT_EXPORT_VIEW_PROPERTY(rate, float); RCT_EXPORT_VIEW_PROPERTY(seek, NSDictionary); -RCT_EXPORT_VIEW_PROPERTY(currentTime, float); RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL); RCT_EXPORT_VIEW_PROPERTY(fullscreenAutorotate, BOOL); RCT_EXPORT_VIEW_PROPERTY(fullscreenOrientation, NSString); From d9e4b1efecd3cc2f6092e0e541e886403f59e849 Mon Sep 17 00:00:00 2001 From: Sunbreak Date: Wed, 15 Mar 2023 09:58:16 +0800 Subject: [PATCH 5/9] fix: remove dummy scaleX/Y & translateX/Y property --- Video.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Video.js b/Video.js index ac6bc085..0f6bb32b 100644 --- a/Video.js +++ b/Video.js @@ -563,11 +563,6 @@ Video.propTypes = { onReceiveAdEvent: PropTypes.func, /* Required by react-native */ - scaleX: PropTypes.number, - scaleY: PropTypes.number, - translateX: PropTypes.number, - translateY: PropTypes.number, - rotation: PropTypes.number, ...ViewPropTypes, }; From 822f8c077476383fbadd2a47c3c4d27d9f8ee082 Mon Sep 17 00:00:00 2001 From: Sunbreak Date: Wed, 15 Mar 2023 09:54:48 +0800 Subject: [PATCH 6/9] fix: remove dummy needsToRestoreUserInterfaceForPictureInPictureStop --- Video.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Video.js b/Video.js index ac6bc085..2aad451a 100644 --- a/Video.js +++ b/Video.js @@ -557,7 +557,6 @@ Video.propTypes = { onAudioFocusChanged: PropTypes.func, onAudioBecomingNoisy: PropTypes.func, onPictureInPictureStatusChanged: PropTypes.func, - needsToRestoreUserInterfaceForPictureInPictureStop: PropTypes.func, onExternalPlaybackChange: PropTypes.func, adTagUrl: PropTypes.string, onReceiveAdEvent: PropTypes.func, From 9519c7bae76486e41b6ab2cf31afa3b8280448dd Mon Sep 17 00:00:00 2001 From: Francesco Benigno Date: Tue, 28 Mar 2023 13:14:48 +0200 Subject: [PATCH 7/9] 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 From 86cd6220bed6fc0c4db048f5e89d8a41b9094b50 Mon Sep 17 00:00:00 2001 From: Francesco Benigno Date: Tue, 28 Mar 2023 13:25:10 +0200 Subject: [PATCH 8/9] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71b54f1c..045d3aca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Version 6.0.0-alpha.5 +- iOS: make sure that the audio in ads is muted when the player is muted. [#3068](https://github.com/react-native-video/react-native-video/pull/3077) - iOS: ensure controls are not displayed when disabled by user [#3017](https://github.com/react-native-video/react-native-video/pull/3017) - iOS: app crashes on call to presentFullScreenPlayer [#2808](https://github.com/react-native-video/react-native-video/pull/2971) - Android: Fix publicated progress handler causing duplicated progress event [#2972](https://github.com/react-native-video/react-native-video/pull/2972) From 2228838075c8901acb53691fd1c7aeb23fec858e Mon Sep 17 00:00:00 2001 From: olivier Date: Wed, 5 Apr 2023 22:41:27 +0200 Subject: [PATCH 9/9] chore: fix changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee575161..660d5573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,11 @@ ### Version 6.0.0-alpha.6 - iOS: remove undocumented `currentTime` property [#3064](https://github.com/react-native-video/react-native-video/pull/3064) +- iOS: make sure that the audio in ads is muted when the player is muted. [#3068](https://github.com/react-native-video/react-native-video/pull/3077) +- iOS: make IMA build optionnal ### Version 6.0.0-alpha.5 -- iOS: make sure that the audio in ads is muted when the player is muted. [#3068](https://github.com/react-native-video/react-native-video/pull/3077) - iOS: ensure controls are not displayed when disabled by user [#3017](https://github.com/react-native-video/react-native-video/pull/3017) - iOS: app crashes on call to presentFullScreenPlayer [#2808](https://github.com/react-native-video/react-native-video/pull/2971) - Android: Fix publicated progress handler causing duplicated progress event [#2972](https://github.com/react-native-video/react-native-video/pull/2972)