diff --git a/src/common/ui-wrapper.ts b/src/common/ui-wrapper.ts index ee69042c8..076b6ee29 100644 --- a/src/common/ui-wrapper.ts +++ b/src/common/ui-wrapper.ts @@ -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']); } else { this._uiManager.buildDefaultUI(); } diff --git a/src/kaltura-player.ts b/src/kaltura-player.ts index e9b9bb40e..4c9359b29 100644 --- a/src/kaltura-player.ts +++ b/src/kaltura-player.ts @@ -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; @@ -830,6 +831,22 @@ export class KalturaPlayer extends FakeEventTarget { return this._localPlayer.Error; } + private _addCustomPreset(options: Partial): 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 diff --git a/src/types/global/globals.d.ts b/src/types/global/globals.d.ts index 08540d544..6f4971356 100644 --- a/src/types/global/globals.d.ts +++ b/src/types/global/globals.d.ts @@ -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;