Merge branch 'master' into AndroidRangePlayback
This commit is contained in:
commit
afcde3e335
13
API.md
13
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
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### tvOS installation
|
||||
@ -935,7 +946,7 @@ Platforms: iOS, Android
|
||||
|
||||
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
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
### Version 6.0.0-alpha.6
|
||||
- Feature: Video range support [#3030](https://github.com/react-native-video/react-native-video/pull/3030)
|
||||
- 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
|
||||
|
||||
|
7
Video.js
7
Video.js
@ -522,7 +522,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,
|
||||
@ -559,17 +558,11 @@ Video.propTypes = {
|
||||
onAudioFocusChanged: PropTypes.func,
|
||||
onAudioBecomingNoisy: PropTypes.func,
|
||||
onPictureInPictureStatusChanged: PropTypes.func,
|
||||
needsToRestoreUserInterfaceForPictureInPictureStop: PropTypes.func,
|
||||
onExternalPlaybackChange: PropTypes.func,
|
||||
adTagUrl: PropTypes.string,
|
||||
onReceiveAdEvent: PropTypes.func,
|
||||
|
||||
/* Required by react-native */
|
||||
scaleX: PropTypes.number,
|
||||
scaleY: PropTypes.number,
|
||||
translateX: PropTypes.number,
|
||||
translateY: PropTypes.number,
|
||||
rotation: PropTypes.number,
|
||||
...ViewPropTypes,
|
||||
};
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,4 @@
|
||||
#if USE_GOOGLE_IMA
|
||||
import Foundation
|
||||
import GoogleInteractiveMediaAds
|
||||
|
||||
@ -76,6 +77,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()
|
||||
@ -185,3 +190,4 @@ class RCTIMAAdsManager: NSObject, IMAAdsLoaderDelegate, IMAAdsManagerDelegate {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -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 {
|
||||
@ -220,10 +226,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, withSource: _source),
|
||||
@ -311,13 +319,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": [
|
||||
@ -428,7 +437,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
|
||||
@ -437,7 +448,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)
|
||||
@ -452,15 +465,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
|
||||
@ -500,6 +504,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
applyModifiers()
|
||||
}
|
||||
|
||||
@objc
|
||||
func isMuted() -> Bool {
|
||||
return _muted
|
||||
}
|
||||
|
||||
@objc
|
||||
func setMuted(_ muted:Bool) {
|
||||
_muted = muted
|
||||
@ -840,11 +849,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
|
||||
}
|
||||
@ -1012,7 +1021,10 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
if _pendingSeek {
|
||||
setCurrentTime(_pendingSeekTime)
|
||||
setSeek([
|
||||
"time": NSNumber(value: _pendingSeekTime),
|
||||
"tolerance": NSNumber(value: 100)
|
||||
])
|
||||
_pendingSeek = false
|
||||
}
|
||||
|
||||
@ -1122,11 +1134,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)
|
||||
|
@ -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);
|
||||
|
@ -19,8 +19,15 @@ Pod::Spec.new do |s|
|
||||
ss.source_files = "ios/Video/**/*.{h,m,swift}"
|
||||
ss.dependency "PromisesSwift"
|
||||
|
||||
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|
|
||||
|
Loading…
Reference in New Issue
Block a user