Custom skin support added for ios. onReceiveAdEvent prop added to catch ad events on ios.
This commit is contained in:
parent
96c717d6df
commit
0f94a3d956
9
Video.js
9
Video.js
@ -253,6 +253,13 @@ export default class Video extends Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_onReceiveAdEvent = (event) => {
|
||||
if (this.props.onReceiveAdEvent) {
|
||||
this.props.onReceiveAdEvent(event.nativeEvent);
|
||||
}
|
||||
};
|
||||
|
||||
getViewManagerConfig = viewManagerName => {
|
||||
if (!NativeModules.UIManager.getViewManagerConfig) {
|
||||
return NativeModules.UIManager[viewManagerName];
|
||||
@ -328,6 +335,7 @@ export default class Video extends Component {
|
||||
onGetLicense: nativeProps.drm && nativeProps.drm.getLicense && this._onGetLicense,
|
||||
onPictureInPictureStatusChanged: this._onPictureInPictureStatusChanged,
|
||||
onRestoreUserInterfaceForPictureInPictureStop: this._onRestoreUserInterfaceForPictureInPictureStop,
|
||||
onReceiveAdEvent: this._onReceiveAdEvent,
|
||||
});
|
||||
|
||||
const posterStyle = {
|
||||
@ -499,6 +507,7 @@ Video.propTypes = {
|
||||
onPictureInPictureStatusChanged: PropTypes.func,
|
||||
needsToRestoreUserInterfaceForPictureInPictureStop: PropTypes.func,
|
||||
onExternalPlaybackChange: PropTypes.func,
|
||||
onReceiveAdEvents: PropTypes.func,
|
||||
|
||||
/* Required by react-native */
|
||||
scaleX: PropTypes.number,
|
||||
|
@ -44,6 +44,7 @@
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onPictureInPictureStatusChanged;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onRestoreUserInterfaceForPictureInPictureStop;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onGetLicense;
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onReceiveAdEvent;
|
||||
|
||||
typedef NS_ENUM(NSInteger, RCTVideoError) {
|
||||
RCTVideoErrorFromJSPart,
|
||||
@ -71,4 +72,6 @@ typedef NS_ENUM(NSInteger, RCTVideoError) {
|
||||
- (void)setLicenseResult:(NSString * )license;
|
||||
- (BOOL)setLicenseResultError:(NSString * )error;
|
||||
|
||||
+ (NSString *)convertEventToString:(IMAAdEventType)event;
|
||||
|
||||
@end
|
||||
|
@ -159,8 +159,6 @@ static int const RCTVideoUnset = -1;
|
||||
viewController.showsPlaybackControls = YES;
|
||||
viewController.rctDelegate = self;
|
||||
viewController.preferredOrientation = _fullscreenOrientation;
|
||||
self.contentPlayhead = [[IMAAVPlayerContentPlayhead alloc] initWithAVPlayer:player];
|
||||
[self setupAdsLoader];
|
||||
|
||||
viewController.view.frame = self.bounds;
|
||||
viewController.player = player;
|
||||
@ -394,6 +392,9 @@ static int const RCTVideoUnset = -1;
|
||||
self->_player = [AVPlayer playerWithPlayerItem:self->_playerItem];
|
||||
self->_player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
|
||||
|
||||
self.contentPlayhead = [[IMAAVPlayerContentPlayhead alloc] initWithAVPlayer:_player];
|
||||
[self setupAdsLoader];
|
||||
|
||||
[self->_player addObserver:self forKeyPath:playbackRate options:0 context:nil];
|
||||
self->_playbackRateObserverRegistered = YES;
|
||||
|
||||
@ -814,6 +815,12 @@ static int const RCTVideoUnset = -1;
|
||||
// When the SDK notifies us that ads have been loaded, play them.
|
||||
[adsManager start];
|
||||
}
|
||||
if (self.onReceiveAdEvent) {
|
||||
NSString *type = [RCTVideo convertEventToString: event.type];
|
||||
self.onReceiveAdEvent(@{@"event": type,
|
||||
@"target": self.reactTag
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdError:(IMAAdError *)error {
|
||||
@ -2093,4 +2100,75 @@ didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest {
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark - helpers
|
||||
+ (NSString *)convertEventToString:(IMAAdEventType)event {
|
||||
NSString *result = nil;
|
||||
switch(event) {
|
||||
case kIMAAdEvent_AD_BREAK_READY:
|
||||
result = @"AD_BREAK_READY";
|
||||
break;
|
||||
case kIMAAdEvent_AD_BREAK_ENDED:
|
||||
result = @"AD_BREAK_ENDED";
|
||||
break;
|
||||
case kIMAAdEvent_AD_BREAK_STARTED:
|
||||
result = @"AD_BREAK_STARTED";
|
||||
break;
|
||||
case kIMAAdEvent_AD_PERIOD_ENDED:
|
||||
result = @"AD_PERIOD_ENDED";
|
||||
break;
|
||||
case kIMAAdEvent_AD_PERIOD_STARTED:
|
||||
result = @"AD_PERIOD_STARTED";
|
||||
break;
|
||||
case kIMAAdEvent_ALL_ADS_COMPLETED:
|
||||
result = @"ALL_ADS_COMPLETED";
|
||||
break;
|
||||
case kIMAAdEvent_CLICKED:
|
||||
result = @"CLICKED";
|
||||
break;
|
||||
case kIMAAdEvent_COMPLETE:
|
||||
result = @"COMPLETE";
|
||||
break;
|
||||
case kIMAAdEvent_CUEPOINTS_CHANGED:
|
||||
result = @"CUEPOINTS_CHANGED";
|
||||
break;
|
||||
case kIMAAdEvent_FIRST_QUARTILE:
|
||||
result = @"FIRST_QUARTILE";
|
||||
break;
|
||||
case kIMAAdEvent_LOADED:
|
||||
result = @"LOADED";
|
||||
break;
|
||||
case kIMAAdEvent_LOG:
|
||||
result = @"LOG";
|
||||
break;
|
||||
case kIMAAdEvent_MIDPOINT:
|
||||
result = @"MIDPOINT";
|
||||
break;
|
||||
case kIMAAdEvent_PAUSE:
|
||||
result = @"PAUSE";
|
||||
break;
|
||||
case kIMAAdEvent_RESUME:
|
||||
result = @"RESUME";
|
||||
break;
|
||||
case kIMAAdEvent_SKIPPED:
|
||||
result = @"SKIPPED";
|
||||
break;
|
||||
case kIMAAdEvent_STARTED:
|
||||
result = @"STARTED";
|
||||
break;
|
||||
case kIMAAdEvent_STREAM_LOADED:
|
||||
result = @"STREAM_LOADED";
|
||||
break;
|
||||
case kIMAAdEvent_TAPPED:
|
||||
result = @"TAPPED";
|
||||
break;
|
||||
case kIMAAdEvent_THIRD_QUARTILE:
|
||||
result = @"THIRD_QUARTILE";
|
||||
break;
|
||||
default:
|
||||
result = @"UNKNOWN";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -71,6 +71,8 @@ RCT_EXPORT_VIEW_PROPERTY(onPlaybackResume, RCTDirectEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onPlaybackRateChange, RCTDirectEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onVideoExternalPlaybackChange, RCTDirectEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onGetLicense, RCTDirectEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onReceiveAdEvent, RCTDirectEventBlock);
|
||||
|
||||
RCT_REMAP_METHOD(save,
|
||||
options:(NSDictionary *)options
|
||||
reactTag:(nonnull NSNumber *)reactTag
|
||||
|
Loading…
Reference in New Issue
Block a user