Skip to content

Commit

Permalink
fix(FEC-9067): playback error with ima on LG TV WebOS (#239)
Browse files Browse the repository at this point in the history
add default configuration for LG TV
  • Loading branch information
Yuvalke committed May 16, 2019
1 parent 6fc6339 commit 99fee11
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ function getDefaultOptions(options: PartialKPOptionsObject): KPOptionsObject {
checkNativeTextTracksSupport(defaultOptions);
setDefaultAnalyticsPlugin(defaultOptions);
configureVrDefaultOptions(defaultOptions);
configureLGTVDefaultOptions(defaultOptions);
configureExternalStreamRedirect(defaultOptions);
return defaultOptions;
}
Expand Down Expand Up @@ -314,6 +315,31 @@ function configureVrDefaultOptions(options: KPOptionsObject): void {
}
}
}

/**
* Sets config option for LG TV
* @private
* @param {KPOptionsObject} options - kaltura player options
* @returns {void}
*/
function configureLGTVDefaultOptions(options: KPOptionsObject): void {
if (isLGTV() && options.plugins && options.plugins.ima) {
const imaForceReload = Utils.Object.getPropertyPath(options, 'plugins.ima.forceReloadMediaAfterAds');
const delayUntilSourceSelected = Utils.Object.getPropertyPath(options, 'plugins.ima.delayInitUntilSourceSelected');
const preferNativeHls = Utils.Object.getPropertyPath(options, 'playback.preferNative.hls');

if (typeof imaForceReload !== 'boolean') {
options = Utils.Object.createPropertyPath(options, 'plugins.ima.forceReloadMediaAfterAds', true);
}
if (typeof preferNativeHls !== 'boolean') {
options = Utils.Object.createPropertyPath(options, 'playback.preferNative.hls', true);
}
if (typeof delayUntilSourceSelected !== 'boolean') {
options = Utils.Object.createPropertyPath(options, 'plugins.ima.delayInitUntilSourceSelected', true);
}
}
}
/**
* Transform options structure from legacy structure to new structure.
* @private
Expand Down Expand Up @@ -390,6 +416,15 @@ function isIos(): boolean {
return Env.os.name === 'iOS';
}
/**
* Returns true if user agent indicate that browser is LG TV
* @private
* @returns {boolean} - if browser is in LG TV
*/
function isLGTV(): boolean {
return /^(?=.*\bweb0s\b)(?=.*\bsmarttv\b).*$/i.test(Env.ua);
}
/**
* set stream priority according to playerConfig
* @param {Player} player - player
Expand Down

0 comments on commit 99fee11

Please sign in to comment.