Skip to content

Commit

Permalink
feat(FEC-9145): support non sibling video tags (#250)
Browse files Browse the repository at this point in the history
set `bumper` default config according to the env and config
  • Loading branch information
yairans authored Jul 4, 2019
1 parent c883355 commit 9c824b8
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 10 deletions.
29 changes: 20 additions & 9 deletions src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,27 @@ function configureDAIDefaultOptions(options: KPOptionsObject): void {
* @returns {void}
*/
function configureBumperDefaultOptions(options: KPOptionsObject): void {
const bumperPlugin = Utils.Object.getPropertyPath(options, 'plugins.bumper');
const daiPlugin = Utils.Object.getPropertyPath(options, 'plugins.imadai');
if (bumperPlugin && !bumperPlugin.disable && daiPlugin && !daiPlugin.disable) {
const bumperConfig = Utils.Object.getPropertyPath(options, 'plugins.bumper');
const daiConfig = Utils.Object.getPropertyPath(options, 'plugins.imadai');
if (bumperConfig) {
const newBumperConfig: Object = {};
if (
typeof bumperConfig.playOnMainVideoTag !== 'boolean' &&
(isLGTV() || (isIos() && options.playback && options.playback.playsinline === false))
) {
newBumperConfig['playOnMainVideoTag'] = true;
}
if (daiConfig && !daiConfig.disable) {
if (!Array.isArray(bumperConfig.position)) {
newBumperConfig['position'] = [0];
}
if (typeof bumperConfig.disableMediaPreload !== 'boolean') {
newBumperConfig['disableMediaPreload'] = true;
}
}
Utils.Object.mergeDeep(options, {
plugins: {
bumper: {
position: [0],
disableMediaPreload: true
}
bumper: newBumperConfig
}
});
}
Expand Down Expand Up @@ -553,9 +565,8 @@ function hasYoutubeSource(sources: PKSourcesConfigObject): boolean {
* @returns {void}
*/
function maybeSetFullScreenConfig(options: KPOptionsObject): void {
const bumperPlugin = Utils.Object.getPropertyPath(options, 'plugins.bumper');
const vrPlugin = Utils.Object.getPropertyPath(options, 'plugins.vr');
if ((bumperPlugin && !bumperPlugin.disable) || (vrPlugin && !vrPlugin.disable)) {
if (vrPlugin && !vrPlugin.disable) {
const fullscreenConfig = Utils.Object.getPropertyPath(options, 'playback.inBrowserFullscreen');
if (typeof fullscreenConfig !== 'boolean') {
Utils.Object.mergeDeep(options, {
Expand Down
62 changes: 61 additions & 1 deletion test/src/common/utils/setup-helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {
isSafari,
setStorageConfig,
supportLegacyOptions,
validateConfig
validateConfig,
getDefaultOptions
} from '../../../../src/common/utils/setup-helpers';
import {Env} from '@playkit-js/playkit-js';

const targetId = 'player-placeholder_setup-helpers.spec';

Expand Down Expand Up @@ -299,3 +301,61 @@ describe('supportLegacyOptions', function() {
duplicateOptions.should.deep.equal(options);
});
});

describe('plugins config', function() {
let sandbox, osName;

beforeEach(function() {
osName = Env.os.name;
sandbox = sinon.sandbox.create();
});

afterEach(function() {
Env.os.name = osName;
sandbox.restore();
});

it('should config bumper plugin according to the env and configuration', function() {
Env.os.name = 'iOS';
const options = {
provider: {
partnerId: 1091
},
playback: {
playsinline: false
},
plugins: {
bumper: {},
imadai: {}
}
};
const defaultOptions = getDefaultOptions(options);
defaultOptions.plugins.bumper.position.should.deep.equal([0]);
defaultOptions.plugins.bumper.disableMediaPreload.should.be.true;
defaultOptions.plugins.bumper.playOnMainVideoTag.should.be.true;
});

it('should not change the bumper plugin', function() {
Env.os.name = 'iOS';
const options = {
provider: {
partnerId: 1091
},
playback: {
playsinline: false
},
plugins: {
bumper: {
playOnMainVideoTag: false,
position: [0, -1],
disableMediaPreload: false
},
imadai: {}
}
};
const defaultOptions = getDefaultOptions(options);
defaultOptions.plugins.bumper.position.should.deep.equal([0, -1]);
defaultOptions.plugins.bumper.disableMediaPreload.should.be.false;
defaultOptions.plugins.bumper.playOnMainVideoTag.should.be.false;
});
});

0 comments on commit 9c824b8

Please sign in to comment.