UNPKG

react-native-theoplayer

Version:

A THEOplayer video component for react-native.

68 lines (67 loc) 2.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NativeOverlayInterstitial = exports.NativeAdBreakInterstitial = void 0; exports.createNativeInterstitial = createNativeInterstitial; var _reactNative = require("react-native"); const NativeTHEOAdsModule = _reactNative.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; } }); } } class NativeAdBreakInterstitial extends NativeInterstitial { type = 'adbreak'; constructor(node, interstitial) { super(node, interstitial); this.layout = interstitial.layout; this.backdropUri = interstitial.backdropUri; this.ads = interstitial.ads; } } exports.NativeAdBreakInterstitial = NativeAdBreakInterstitial; 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; } } exports.NativeOverlayInterstitial = NativeOverlayInterstitial; 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