Skip to content

Commit

Permalink
feat(FEC-13664): add applyTextTrackStyles method (#261)
Browse files Browse the repository at this point in the history
### Description of the Changes

add `applyTextTrackStyles` method that allows apply custom styles to
text-track

**Fix:**

#### Resolves https://kaltura.atlassian.net/browse/FEC-13664
  • Loading branch information
semarche-kaltura committed Mar 18, 2024
1 parent c8cae03 commit f849d47
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/dash-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
* @static
*/
protected static _logger = BaseMediaSourceAdapter.getLogger(DashAdapter.id);

public static textContainerClass = "shaka-text-container";

Check warning on line 92 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / canary / canary / running-tests / running-tests (ubuntu-latest)

Strings must use singlequote

Check warning on line 92 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / prod / running-tests / running-tests (ubuntu-latest)

Strings must use singlequote

/**
* The supported mime type by the dash adapter
* @member {string} _dashMimeType
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f849d47

Please sign in to comment.