Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SUP-44085): Two different players on the same page #842

Merged
merged 11 commits into from
Sep 4, 2024
4 changes: 2 additions & 2 deletions src/common/ui-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class UIWrapper {
}
} else {
this._uiManager = new UIManager(player, config);
if (config.customPreset || window.kalturaCustomPreset) {
this._uiManager.buildCustomUI(config.customPreset || window.kalturaCustomPreset);
if (config.customPreset || (window.kalturaCustomPresetMap && window.kalturaCustomPresetMap[config.targetId])) {
this._uiManager.buildCustomUI(config.customPreset || window.kalturaCustomPresetMap[config.targetId]['audioPlayer']);
SivanA-Kaltura marked this conversation as resolved.
Show resolved Hide resolved
} else {
this._uiManager.buildDefaultUI();
}
Expand Down
17 changes: 17 additions & 0 deletions src/kaltura-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class KalturaPlayer extends FakeEventTarget {
this._sessionIdCache = new SessionIdCache();
this._configEvaluator = new ConfigEvaluator();
this._configEvaluator.evaluatePluginsConfig(plugins, options);
this._addCustomPreset(options);
this._playbackStart = false;
const noSourcesOptions = Utils.Object.mergeDeep({}, options);
delete noSourcesOptions.plugins;
Expand Down Expand Up @@ -830,6 +831,22 @@ export class KalturaPlayer extends FakeEventTarget {
return this._localPlayer.Error;
}

private _addCustomPreset(options: Partial<KalturaPlayerConfig>): void {
if (options.plugins) {
Object.keys(options.plugins).forEach((plugin) => {
if (window.kalturaCustomPreset && window.kalturaCustomPreset[plugin]) {
if (!window.kalturaCustomPresetMap) {
window.kalturaCustomPresetMap = {};
}
if (!window.kalturaCustomPresetMap[options.ui!.targetId]) {
window.kalturaCustomPresetMap[options.ui!.targetId] = {};
}
window.kalturaCustomPresetMap[options.ui!.targetId][plugin] = window.kalturaCustomPreset[plugin];
}
});
}
}

private _configureInformationForDevice(mediaConfig: KPMediaConfig): void {
// here we can provide information about the media, to a device that is playing it
// set the media metadata title to the name of the entry, if exists
Expand Down
1 change: 1 addition & 0 deletions src/types/global/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// globals.d.ts
declare var __kalturaplayerdata: any;
declare var kalturaCustomPreset: any;
declare var kalturaCustomPresetMap: any;
declare var DEBUG_KALTURA_PLAYER: boolean;
declare var __NAME__: string;
declare var __VERSION__: string;
Expand Down
Loading