Skip to content

Commit

Permalink
feat(FEC-9227): support reInit of MSE (#254)
Browse files Browse the repository at this point in the history
Add configuration to handle ads with MSE
  • Loading branch information
Yuvalke authored Jul 19, 2019
1 parent dfe18ac commit 2b78cd7
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,41 @@ function checkNativeTextTracksSupport(options: KPOptionsObject): void {
}
}

/**
* Sets config option for Ads with MSE
* @private
* @param {KPOptionsObject} options - kaltura player options
* @returns {void}
*/
function _configureAdsWithMSE(options: KPOptionsObject): void {
const playAdsWithMSE = Utils.Object.getPropertyPath(options, 'playback.playAdsWithMSE');
//dai should play without playAdsWithMSE config
if (typeof playAdsWithMSE !== 'boolean') {
if (options.plugins && options.plugins.imadai && !options.plugins.imadai.disable) {
options = Utils.Object.createPropertyPath(options, 'playback.playAdsWithMSE', false);
} else {
options = Utils.Object.createPropertyPath(options, 'playback.playAdsWithMSE', true);
}
}
const disableMediaPreloadIma = Utils.Object.getPropertyPath(options, 'plugins.ima.disableMediaPreload');
const disableMediaPreloadBumper = Utils.Object.getPropertyPath(options, 'plugins.bumper.disableMediaPreload');

if (options.plugins && options.plugins.ima && typeof disableMediaPreloadIma !== 'boolean') {
options = Utils.Object.createPropertyPath(options, 'plugins.ima.disableMediaPreload', true);
}
if (options.plugins && options.plugins.bumper && typeof disableMediaPreloadBumper !== 'boolean') {
options = Utils.Object.createPropertyPath(options, 'plugins.bumper.disableMediaPreload', true);
}
}
/**
* Sets config option for LG TV
* @private
* @param {KPOptionsObject} options - kaltura player options
* @returns {void}
*/
function configureLGTVDefaultOptions(options: KPOptionsObject): void {
if (isLGTV()) {
const preferNativeHls = Utils.Object.getPropertyPath(options, 'playback.preferNative.hls');
if (typeof preferNativeHls !== 'boolean') {
options = Utils.Object.createPropertyPath(options, 'playback.preferNative.hls', true);
}
if (isSmartTv()) {
_configureAdsWithMSE(options);
if (options.plugins && options.plugins.ima) {
const imaForceReload = Utils.Object.getPropertyPath(options, 'plugins.ima.forceReloadMediaAfterAds');
const delayUntilSourceSelected = Utils.Object.getPropertyPath(options, 'plugins.ima.delayInitUntilSourceSelected');
Expand Down Expand Up @@ -392,7 +415,7 @@ function configureBumperDefaultOptions(options: KPOptionsObject): void {
const newBumperConfig: Object = {};
if (
typeof bumperConfig.playOnMainVideoTag !== 'boolean' &&
(isLGTV() || (isIos() && options.playback && options.playback.playsinline === false))
(isSmartTv() || (isIos() && options.playback && options.playback.playsinline === false))
) {
newBumperConfig['playOnMainVideoTag'] = true;
}
Expand Down Expand Up @@ -514,12 +537,12 @@ function isIos(): boolean {
}
/**
* Returns true if user agent indicate that browser is LG TV
* Returns true if user agent indicate that browser is smart TV
* @private
* @returns {boolean} - if browser is in LG TV
*/
function isLGTV(): boolean {
return Env.os.name.toLowerCase() === 'web0s';
function isSmartTv(): boolean {
return Env.os.name.toLowerCase() === 'web0s' || Env.os.name.toLowerCase() === 'tizen';
}
/**
Expand Down

0 comments on commit 2b78cd7

Please sign in to comment.