Skip to content

Commit

Permalink
fix(FEC-8826): fullscreen implementation moved to core (#227)
Browse files Browse the repository at this point in the history
Element as parameter to open in fullscreen
  • Loading branch information
Yuvalke committed Apr 1, 2019
1 parent 58850a0 commit faa5fd7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 13 deletions.
6 changes: 0 additions & 6 deletions src/common/ui-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,10 @@ class UIWrapper {

_handleVr(config: PKPluginsConfigObject = {}): void {
if (config.vr && !config.vr.disable) {
this._setFullscreenConfig();
this._setStereoConfig(config.vr);
}
}

_setFullscreenConfig(): void {
const fullscreenConfig = Utils.Object.getPropertyPath(this._uiManager, 'config.components.fullscreen');
this.setConfig(Utils.Object.mergeDeep({}, {inBrowserFullscreenForIOS: true}, fullscreenConfig), 'fullscreen');
}

_setStereoConfig(vrConfig: Object): void {
if (vrConfig.toggleStereo || (Env.device.type && vrConfig.toggleStereo !== false)) {
// enable stereo mode by default for mobile device
Expand Down
34 changes: 29 additions & 5 deletions src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ function getDefaultOptions(options: PartialKPOptionsObject): KPOptionsObject {
checkNativeHlsSupport(defaultOptions);
checkNativeTextTracksSupport(defaultOptions);
setDefaultAnalyticsPlugin(defaultOptions);
configureVrDefaultOptions(defaultOptions);
configureExternalStreamRedirect(defaultOptions);
configureDelayAdsInitialization(defaultOptions);
return defaultOptions;
Expand Down Expand Up @@ -318,6 +319,24 @@ function checkNativeTextTracksSupport(options: KPOptionsObject): void {
}
}

/**
* Sets config option fullscreen element for Vr Mode support
* @private
* @param {KPOptionsObject} options - kaltura player options
* @returns {void}
*/
function configureVrDefaultOptions(options: KPOptionsObject): void {
if (options.plugins && options.plugins.vr && !options.plugins.vr.disable) {
const fullscreenConfig = Utils.Object.getPropertyPath(options, 'playback.inBrowserFullscreen');
if (typeof fullscreenConfig !== 'boolean') {
Utils.Object.mergeDeep(options, {
playback: {
inBrowserFullscreen: true
}
});
}
}
}
/**
* Transform options structure from legacy structure to new structure.
* @private
Expand All @@ -342,10 +361,14 @@ function supportLegacyOptions(options: Object): PartialKPOptionsObject {
level: 'warn',
msg: `Path config.player.${propPath} will be deprecated soon. Please update your config structure as describe here: ${__CONFIG_DOCS_URL__}`
});
const propValue = Utils.Object.getPropertyPath(options, propPath);
const propObj = Utils.Object.createPropertyPath({}, targetPath, propValue);
Utils.Object.mergeDeep(options, propObj);
Utils.Object.deletePropertyPath(options, propPath);
if (!Utils.Object.hasPropertyPath(options, targetPath)) {
const propValue = Utils.Object.getPropertyPath(options, propPath);
const propObj = Utils.Object.createPropertyPath({}, targetPath, propValue);
Utils.Object.mergeDeep(options, propObj);
Utils.Object.deletePropertyPath(options, propPath);
} else {
Utils.Object.deletePropertyPath(options, propPath);
}
}
};
const moves = [
Expand All @@ -355,7 +378,8 @@ function supportLegacyOptions(options: Object): PartialKPOptionsObject {
['id', 'sources.id'],
['name', 'metadata.name'],
['metadata.poster', 'sources.poster'],
['metadata', 'sources.metadata']
['metadata', 'sources.metadata'],
['ui.components.fullscreen.inBrowserFullscreenForIOS', 'playback.inBrowserFullscreen']
];
removePlayerEntry();
moves.forEach(move => moveProp(move[0], move[1]));
Expand Down
4 changes: 2 additions & 2 deletions src/kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ class KalturaPlayer extends FakeEventTarget {
this._localPlayer.notifyExitFullscreen();
}

enterFullscreen(): void {
this._localPlayer.enterFullscreen();
enterFullscreen(fullScreenElement: ?HTMLElement): void {
this._localPlayer.enterFullscreen(fullScreenElement);
}

exitFullscreen(): void {
Expand Down
34 changes: 34 additions & 0 deletions test/src/common/utils/setup-helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,35 @@ describe('supportLegacyOptions', function() {
}
};

const duplicateOptions = {
targetId: 'player-placeholder',
sources: {
dvr: false
},
player: {
dvr: true,
type: 'Live',
duration: 10000,
name: 'name',
playback: {
autoplay: false
},
metadata: {
poster: 'https://www.elastic.co/assets/bltada7771f270d08f6/enhanced-buzz-1492-1379411828-15.jpg'
}
},
provider: {
partnerId: 1091
},
ui: {
components: {
seekbar: {
thumbsSprite: 'http://stilearning.com/vision/1.1/assets/globals/img/dummy/img-10.jpg'
}
}
}
};

const options = {
targetId: 'player-placeholder',
sources: {
Expand Down Expand Up @@ -261,4 +290,9 @@ describe('supportLegacyOptions', function() {
supportLegacyOptions(options);
legacyOptions.should.deep.equal(options);
});

it('check method support duplicate configuration take the new configuration', function() {
supportLegacyOptions(duplicateOptions);
duplicateOptions.should.deep.equal(options);
});
});

0 comments on commit faa5fd7

Please sign in to comment.