react-native-theoplayer
Version:
A THEOplayer video component for react-native.
61 lines (60 loc) • 2.06 kB
JavaScript
"use strict";
import { NativeModules } from 'react-native';
const NativeTHEOAdsModule = NativeModules.THEORCTTHEOAdsModule;
class NativeInterstitial {
constructor(node, interstitial) {
this.node = node;
this.id = interstitial.id;
this.type = interstitial.type;
this.startTime = interstitial.startTime;
this.duration = interstitial.duration;
this._adTagParameters = this.createAdTagParametersProxy(interstitial.adTagParameters);
}
get adTagParameters() {
return this._adTagParameters;
}
set adTagParameters(newAdTagParamters) {
this._adTagParameters = this.createAdTagParametersProxy(newAdTagParamters);
NativeTHEOAdsModule.setAdTagParameters(this.node, this.id, newAdTagParamters);
}
createAdTagParametersProxy(target) {
return new Proxy(target, {
set: (adTagParameters, key, newValue) => {
const currentValue = adTagParameters[key];
adTagParameters[key] = newValue;
if (currentValue !== newValue) {
NativeTHEOAdsModule.setAdTagParameters(this.node, this.id, adTagParameters);
}
return true;
}
});
}
}
export class NativeAdBreakInterstitial extends NativeInterstitial {
type = 'adbreak';
constructor(node, interstitial) {
super(node, interstitial);
this.layout = interstitial.layout;
this.backdropUri = interstitial.backdropUri;
this.ads = interstitial.ads;
}
}
export class NativeOverlayInterstitial extends NativeInterstitial {
type = 'overlay';
constructor(node, interstitial) {
super(node, interstitial);
this.imageUrl = interstitial.imageUrl;
this.clickThrough = interstitial.clickThrough;
this.position = interstitial.position;
this.size = interstitial.size;
}
}
export function createNativeInterstitial(node, interstitial) {
switch (interstitial.type) {
case 'adbreak':
return new NativeAdBreakInterstitial(node, interstitial);
case 'overlay':
return new NativeOverlayInterstitial(node, interstitial);
}
}
//# sourceMappingURL=NativeInterstitialAdapter.js.map