@playkit-js/playkit-js-ui
Version:
[](https://github.com/kaltura/playkit-js-ui/actions/workflows/run_canary_full_flow.yaml) [ • 1.77 kB
text/typescript
import {BottomBarNeedsResizeEvent} from '../../event/events/bottom-bar-needs-resize-event';
export interface IconComponent {
registerComponent(): any;
getSvgIcon(): any;
getComponentText(): any;
}
export class BottomBarRegistryManager {
private _registry: Map<string, any>;
constructor() {
this._registry = new Map();
}
public register(componentName: string, componentIcon: any): void {
if (!this.getComponentItem(componentName)) {
this._registry.set(componentName, componentIcon);
}
}
public unregister(componentName: string): void {
if (this.getComponentItem(componentName)) {
this._registry.delete(componentName);
}
}
public getComponentItem(componentName: string): any {
return this._registry.get(componentName);
}
public clear(): void {
this._registry.clear();
}
}
export const bottomBarRegistryManager: string = 'bottomBarRegistryManager';
export const registerToBottomBar = (componentName: string, player: any, getIconDtoCallback: () => any): void => {
const bottomBarRegistry = (player?.getService(bottomBarRegistryManager) as BottomBarRegistryManager) || undefined;
if (bottomBarRegistry && !bottomBarRegistry.getComponentItem(componentName)) {
bottomBarRegistry.register(componentName, getIconDtoCallback());
player.dispatchEvent(new BottomBarNeedsResizeEvent());
}
};
export const unregisterFromBottomBar = (componentName: string, player: any): void => {
const bottomBarRegistry = (player?.getService(bottomBarRegistryManager) as BottomBarRegistryManager) || undefined;
if (bottomBarRegistry && bottomBarRegistry.getComponentItem(componentName)) {
bottomBarRegistry.unregister(componentName);
player.dispatchEvent(new BottomBarNeedsResizeEvent());
}
};