Files
ShakaPlayer/ui/icon_registry.js
Phyo Wai LinandÁlvaro Velad Galván e7b1e5a0f6 feat(UI): Ability to change UI icons (#9115)
## How to register a custom icon?

**Icons need to be registered before initializing the player.**

Register a custom icon from  Material Symbols:

```js
shaka.ui.IconRegistry.register('<PATH_VALUE>');
```

Register a custom Icon from any icon set:

```js
shaka.ui.IconRegistry.register('<NAME>', {
  path: '<PATH_VALUE>',
  viewBox: '<VIEW_BOX>',
  size:  24, // optional
});
```

Register a custom Icon (that contains multiple paths) from any icon set:

```js
shaka.ui.IconRegistry.register('<NAME>', {
  path: ['<PATH_VALUE_1>', '<PATH_VALUE_2>'],
  viewBox: '<VIEW_BOX>',
  size:  24, // optional
});
```

Register a custom Icon using URL of the icon:

```js
shaka.ui.IconRegistry.register('<NAME>', {
  url: '<URL>',
  size:  24, // optional
});
```

Closes: #9045

---------

Co-authored-by: Álvaro Velad Galván <[email protected]>
2025-09-19 11:59:17 +02:00

30 lines
629 B
JavaScript

/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('shaka.ui.IconRegistry');
goog.require('shaka.ui.Enums');
/**
* @final
* @export
*/
shaka.ui.IconRegistry = class IconRegistry {
/**
* Register custom icon for UI control elements
* If a single string is passed, it is treated as an SVG path
* @param {string} name
* @param {shaka.extern.UIIcon | string} icon
* @export
*/
static register(name, icon) {
if (typeof icon === 'object' || typeof icon == 'string') {
shaka.ui.Enums.MaterialDesignSVGIcons[name] = icon;
}
}
};