From f849d47af7ecedab61e9c420d13dd91f1c40307f Mon Sep 17 00:00:00 2001 From: Serhii Date: Mon, 18 Mar 2024 11:29:37 +0200 Subject: [PATCH] feat(FEC-13664): add applyTextTrackStyles method (#261) ### Description of the Changes add `applyTextTrackStyles` method that allows apply custom styles to text-track **Fix:** #### Resolves https://kaltura.atlassian.net/browse/FEC-13664 --- src/dash-adapter.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/dash-adapter.ts b/src/dash-adapter.ts index 372c20c..1a0dcdd 100644 --- a/src/dash-adapter.ts +++ b/src/dash-adapter.ts @@ -88,6 +88,9 @@ export default class DashAdapter extends BaseMediaSourceAdapter { * @static */ protected static _logger = BaseMediaSourceAdapter.getLogger(DashAdapter.id); + + public static textContainerClass = "shaka-text-container"; + /** * The supported mime type by the dash adapter * @member {string} _dashMimeType @@ -230,6 +233,16 @@ export default class DashAdapter extends BaseMediaSourceAdapter { private _selectedVideoTrack: VideoTrack | undefined | null = null; private _playbackActualUri: string | undefined; + public applyTextTrackStyles(sheet: CSSStyleSheet, styles: any, containerId: string): void { + const flexAlignment = { + left: 'flex-start', + center: 'center', + right: 'flex-end', + } + sheet.insertRule(`#${containerId} .${DashAdapter.textContainerClass} { align-items: ${flexAlignment[styles.textAlign]}!important; }`, 0); + sheet.insertRule(`#${containerId} .${DashAdapter.textContainerClass} > * { ${styles.toCSS()} }`, 0); + } + /** * Factory method to create media source adapter. * @function createAdapter