Skip to content

Commit

Permalink
fix(FEC-8131): skippable ads fail on iOS (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv authored and OrenMe committed Apr 22, 2018
1 parent 2e08843 commit 9b1940c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @flow
import {setDefaultAnalyticsPlugin} from 'player-defaults'
import {Utils, TextStyle, Env} from 'playkit-js'
import {Env, TextStyle, Utils} from 'playkit-js'
import {ValidationErrorType} from './validation-error'
import StorageManager from '../storage/storage-manager'
import {setLogLevel as _setLogLevel, LogLevel} from './logger'
import {configureExternalStreamRedirect} from './external-stream-redirect-helper'
import type {LogLevelObject} from './logger'
import {LogLevel, setLogLevel as _setLogLevel} from './logger'
import {configureExternalStreamRedirect} from './external-stream-redirect-helper'

const CONTAINER_CLASS_NAME: string = 'kaltura-player-container';
const KALTURA_PLAYER_DEBUG_QS: string = 'debugKalturaPlayer';
Expand Down Expand Up @@ -200,6 +200,7 @@ function getDefaultOptions(options: PartialKalturaPlayerOptionsObject): KalturaP
checkNativeTextTracksSupport(defaultOptions.player);
setDefaultAnalyticsPlugin(defaultOptions.player);
configureExternalStreamRedirect(defaultOptions.player);
configureDelayAdsInitialization(defaultOptions.player);
return defaultOptions;
}

Expand All @@ -223,6 +224,27 @@ function checkNativeHlsSupport(playerConfig: PKPlayerOptionsObject): void {
}
}

/**
* Configures the delayInitUntilSourceSelected property for the ads plugin based on the runtime platform and the playsinline config value.
* @param {PKPlayerOptionsObject} playerConfig - the player config
* @returns {void}
*/
function configureDelayAdsInitialization(playerConfig: PKPlayerOptionsObject): void {
if (isIos() && playerConfig.plugins && playerConfig.plugins.ima) {
const playsinline = Utils.Object.getPropertyPath(playerConfig, 'playback.playsinline');
const delayInitUntilSourceSelected = Utils.Object.getPropertyPath(playerConfig, 'plugins.ima.delayInitUntilSourceSelected');
if ((typeof playsinline !== 'boolean' || playsinline === true) && (typeof delayInitUntilSourceSelected !== 'boolean')) {
Utils.Object.mergeDeep(playerConfig, {
plugins: {
ima: {
delayInitUntilSourceSelected: true
}
}
});
}
}
}

/**
* Sets config option for native text track support
* @param {PKPlayerOptionsObject} playerConfig - the player config
Expand Down

0 comments on commit 9b1940c

Please sign in to comment.