UNPKG

@playkit-js/playkit-js-ui

Version:

[![Build Status](https://github.com/kaltura/playkit-js-ui/actions/workflows/run_canary_full_flow.yaml/badge.svg)](https://github.com/kaltura/playkit-js-ui/actions/workflows/run_canary_full_flow.yaml) [![code style: prettier](https://img.shields.io/badge/c

43 lines (34 loc) 1.22 kB
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()); } };