From a94a60213dd7e84473c3f3c8bcfef861a6c939b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 9 Jan 2024 09:39:33 +0100 Subject: [PATCH] feat(UI): Separate trackLabelFormat settings for text tracks and audio tracks (#6052) Closes https://github.com/shaka-project/shaka-player/issues/6008 --- ui/externs/ui.js | 15 +++++++++++++-- ui/text_selection.js | 2 +- ui/ui.js | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ui/externs/ui.js b/ui/externs/ui.js index 1d6b0c01b5..31a2563062 100644 --- a/ui/externs/ui.js +++ b/ui/externs/ui.js @@ -87,6 +87,7 @@ shaka.extern.UIVolumeBarColors; * seekBarColors: shaka.extern.UISeekBarColors, * volumeBarColors: shaka.extern.UIVolumeBarColors, * trackLabelFormat: shaka.ui.Overlay.TrackLabelFormat, + * textTrackLabelFormat: shaka.ui.Overlay.TrackLabelFormat, * fadeDelay: number, * doubleClickForFullscreen: boolean, * singleClickForPlayAndPause: boolean, @@ -156,8 +157,18 @@ shaka.extern.UIVolumeBarColors; * colors used in the linear gradient constructed in JavaScript, since you * cannot do this in pure CSS. * @property {shaka.ui.Overlay.TrackLabelFormat} trackLabelFormat - * An enum that determines what is shown in the labels for text track and - * audio variant selection. + * An enum that determines what is shown in the labels for audio variant + * selection. + * LANGUAGE means that only the language of the item is shown. + * ROLE means that only the role of the item is shown. + * LANGUAGE_ROLE means both language and role are shown, or just language if + * there is no role. + * LABEL means the non-standard DASH "label" attribute or the standard DASH + * "Label" element or the HLS "NAME" attribute are shown. + * Defaults to LANGUAGE. + * @property {shaka.ui.Overlay.TrackLabelFormat} textTrackLabelFormat + * An enum that determines what is shown in the labels for text track + * selection. * LANGUAGE means that only the language of the item is shown. * ROLE means that only the role of the item is shown. * LANGUAGE_ROLE means both language and role are shown, or just language if diff --git a/ui/text_selection.js b/ui/text_selection.js index 89b71e1bfa..b7b23a570f 100644 --- a/ui/text_selection.js +++ b/ui/text_selection.js @@ -135,7 +135,7 @@ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu { this.player.isTextTrackVisible(), this.currentSelection, this.localization, - this.controls.getConfig().trackLabelFormat, + this.controls.getConfig().textTrackLabelFormat, this.controls.getConfig().showAudioChannelCountVariants); // Add the Off button diff --git a/ui/ui.js b/ui/ui.js index 222f2d7672..23b5101057 100644 --- a/ui/ui.js +++ b/ui/ui.js @@ -237,6 +237,7 @@ shaka.ui.Overlay = class { level: 'rgb(255, 255, 255)', }, trackLabelFormat: shaka.ui.Overlay.TrackLabelFormat.LANGUAGE, + textTrackLabelFormat: shaka.ui.Overlay.TrackLabelFormat.LANGUAGE, fadeDelay: 0, doubleClickForFullscreen: true, singleClickForPlayAndPause: true,