UNPKG

@playkit-js/playkit-js

Version:

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

25 lines (21 loc) 791 B
import * as Utils from './util'; /** * The text style class name. * @type {string} * @const */ const SUBTITLES_STYLE_CLASS_NAME: string = 'playkit-subtitles-style'; export const getSubtitleStyleSheet = (playerId: string): CSSStyleSheet => { let element = Utils.Dom.getElementBySelector(`.${playerId}.${SUBTITLES_STYLE_CLASS_NAME}`); if (!element) { element = Utils.Dom.createElement('style'); Utils.Dom.addClassName(element, playerId); Utils.Dom.addClassName(element, SUBTITLES_STYLE_CLASS_NAME); Utils.Dom.appendChild(document.head, element); } return element.sheet; }; export const resetSubtitleStyleSheet = (playerId: string): void => { const element = Utils.Dom.getElementBySelector(`.${playerId}.${SUBTITLES_STYLE_CLASS_NAME}`); element?.remove(); };