Skip to content

Commit

Permalink
Enabled iOS preroll playing (problems: Video not showing and link not…
Browse files Browse the repository at this point in the history
… opening Safari)
  • Loading branch information
Adrien Thiery committed Jan 4, 2018
1 parent 86d29b1 commit 1fbd9bd
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/brightcove-video/brightcove-player.defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
width: 320,
height: 180,
playerId: "default",
vastTag: null,
onError: () => {},
onPlay: () => {},
onPause: () => {},
Expand Down
1 change: 1 addition & 0 deletions packages/brightcove-video/brightcove-player.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class BrightcoveVideo extends Component {
zIndex: this.props.zIndex
}}
policyKey={this.props.policyKey}
vastTag={this.props.vastTag}
accountId={this.props.accountId}
videoId={this.props.videoId}
autoplay={this.props.autoplay}
Expand Down
1 change: 1 addition & 0 deletions packages/brightcove-video/brightcove-player.proptypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const numberOrString = PropTypes.oneOfType([
export default {
videoId: PropTypes.string.isRequired,
accountId: PropTypes.string.isRequired,
vastTag: PropTypes.string.isRequired,
policyKey: PropTypes.string,
playerId: PropTypes.string,
width: numberOrString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@
"$(SRCROOT)/../../../../ios/Pods/Headers/Public/Brightcove-Player-Core",
"$(SRCROOT)/../../../../React/**",
"$(SRCROOT)/../../../react-native/React/**",
"$(SRCROOT)/../../../../ios/Pods/Headers/Public/Brightcove-Player-IMA",
"$(SRCROOT)/../../../../ios/Pods/Headers/Public/GoogleAds-IMA-iOS-SDK",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
Expand All @@ -309,6 +311,8 @@
"$(SRCROOT)/../../../../ios/Pods/Headers/Public/Brightcove-Player-Core",
"$(SRCROOT)/../../../../React/**",
"$(SRCROOT)/../../../react-native/React/**",
"$(SRCROOT)/../../../../ios/Pods/Headers/Public/Brightcove-Player-IMA",
"$(SRCROOT)/../../../../ios/Pods/Headers/Public/GoogleAds-IMA-iOS-SDK",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@implementation RNTBrightcoveManager

RCT_EXPORT_MODULE();
RCT_EXPORT_VIEW_PROPERTY(vastTag, NSString);
RCT_EXPORT_VIEW_PROPERTY(policyKey, NSString);
RCT_EXPORT_VIEW_PROPERTY(accountId, NSString);
RCT_EXPORT_VIEW_PROPERTY(videoId, NSString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
#import <React/RCTEventDispatcher.h>
#import <React/RCTView.h>
#import <BrightcovePlayerSDK/BrightcovePlayerSDK.h>
#import <BrightcoveIMA/BrightcoveIMA.h>
#import <GoogleInteractiveMediaAds/GoogleInteractiveMediaAds.h>

@class RCTEventDispatcher;

@interface RNTBrightcoveView : UIView

@property (nonatomic, copy) NSString *policyKey;
@property (nonatomic, copy) NSString *vastTag;
@property (nonatomic, copy) NSString *accountId;
@property (nonatomic, copy) NSString *videoId;
@property (nonatomic, assign) BOOL autoplay;
Expand Down
38 changes: 31 additions & 7 deletions packages/brightcove-video/ios/RNTBrightcove/RNTBrightcoveView.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,25 @@ - (void)setup {
_progress = 0;
_isFinished = NO;

IMASettings *imaSettings = [[IMASettings alloc] init];
imaSettings.language = @"fr-CA";

IMAAdsRenderingSettings *renderSettings = [[IMAAdsRenderingSettings alloc] init];
renderSettings.webOpenerPresentingController = self.fullscreenViewController;

BCOVIMAAdsRequestPolicy *adsRequestPolicy = [BCOVIMAAdsRequestPolicy adsRequestPolicyWithVMAPAdTagUrl:_vastTag];

BCOVPlayerSDKManager *manager = [BCOVPlayerSDKManager sharedManager];
_playbackController =
[manager createIMAPlaybackControllerWithSettings:imaSettings
adsRenderingSettings:renderSettings
adsRequestPolicy:adsRequestPolicy
adContainer:self
companionSlots:nil
viewStrategy:nil];

_playbackController = [manager createPlaybackController];
_playbackController.delegate = self;
_playbackController.autoAdvance = YES;
_playbackController.autoAdvance = YES;
_playbackController.autoPlay = [_autoplayNumber boolValue];

_playbackService = [[BCOVPlaybackService alloc] initWithAccountId:_accountId
Expand All @@ -83,11 +97,15 @@ - (void)layoutSubviews {

- (void)removeFromSuperview {
_eventDispatcher = nil;
for (UIView *subView in self.subviews)
{
[subView removeFromSuperview];
}
[super removeFromSuperview];
}

- (void)initPlayerView {
if (_policyKey && _accountId && _videoId && _autoplayNumber && _hideFullScreenButtonNumber) {
if (_policyKey && _accountId && _videoId && _autoplayNumber && _hideFullScreenButtonNumber && _vastTag) {
[self setup];

BCOVPUIBasicControlView *controlsView = [BCOVPUIBasicControlView basicControlViewWithVODLayout];
Expand All @@ -109,7 +127,6 @@ - (void)initPlayerView {
playerView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

_playerView = playerView;
_playerView.playbackController = _playbackController;

[self requestContentFromPlaybackService];
}
Expand All @@ -122,6 +139,13 @@ - (void)setPolicyKey:(NSString *)policyKey {
}
}

- (void)setVASTTag:(NSString *)vastTag {
if (![vastTag isEqual:_vastTag]) {
_vastTag = vastTag;
[self initPlayerView];
}
}

- (void)setAccountId:(NSString *)accountId {
if (![accountId isEqual:_accountId]) {
_accountId = accountId;
Expand Down Expand Up @@ -228,16 +252,16 @@ - (UIViewController *)rootViewController{
}

- (RNTFullscreenPresentingAutoRotatingViewController *)fullscreenViewController {

if (_fullscreenViewController) {
return _fullscreenViewController;
}

RNTFullscreenPresentingAutoRotatingViewController* vc = [RNTFullscreenPresentingAutoRotatingViewController new];
vc.viewControllerToPresentFrom = [self rootViewController];

_fullscreenViewController = vc;

return _fullscreenViewController;

}
Expand Down

0 comments on commit 1fbd9bd

Please sign in to comment.