Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UI): Add config to show the audio codec in the audio selector #7644

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/audio_language_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ shaka.ui.AudioLanguageSelection = class extends shaka.ui.SettingsMenu {
(track) => this.onAudioTrackSelected_(track),
/* updateChosen= */ true, this.currentSelection, this.localization,
this.controls.getConfig().trackLabelFormat,
this.controls.getConfig().showAudioChannelCountVariants);
this.controls.getConfig().showAudioChannelCountVariants,
this.controls.getConfig().showAudioCodec);
shaka.ui.Utils.focusOnTheChosenItem(this.menu);

this.controls.dispatchEvent(
Expand Down
6 changes: 5 additions & 1 deletion ui/externs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ shaka.extern.UIVolumeBarColors;
* displayInVrMode: boolean,
* defaultVrProjectionMode: string,
* setupMediaSession: boolean,
* preferVideoFullScreenInVisionOS: boolean
* preferVideoFullScreenInVisionOS: boolean,
* showAudioCodec: boolean
* }}
*
* @property {!Array.<string>} controlPanelElements
Expand Down Expand Up @@ -261,6 +262,9 @@ shaka.extern.UIVolumeBarColors;
* experiences that are only allowed with the fullscreen of the video element
* itself.
* Defaults to false.
* @property {boolean} showAudioCodec
* Show the audio codec if the language has more than one audio codec.
* Defaults to true.
* @exportDoc
*/
shaka.extern.UIConfiguration;
Expand Down
11 changes: 6 additions & 5 deletions ui/language_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ shaka.ui.LanguageUtils = class {
* @param {shaka.ui.Localization} localization
* @param {shaka.ui.Overlay.TrackLabelFormat} trackLabelFormat
* @param {boolean} showAudioChannelCountVariants
* @param {boolean} showAudioCodec
*/
static updateTracks(tracks, langMenu, onTrackSelected, updateChosen,
currentSelectionElement, localization, trackLabelFormat,
showAudioChannelCountVariants) {
showAudioChannelCountVariants, showAudioCodec) {
const LocIds = shaka.ui.Locales.Ids;

// TODO: Do the benefits of having this common code in a method still
Expand Down Expand Up @@ -82,7 +83,7 @@ shaka.ui.LanguageUtils = class {
if (showAudioChannelCountVariants && channelsCount != null) {
keys.push(channelsCount);
}
if (hasDifferentAudioCodecs(language) && audioCodec) {
if (showAudioCodec && hasDifferentAudioCodecs(language) && audioCodec) {
keys.push(audioCodec);
}
if (label &&
Expand Down Expand Up @@ -162,7 +163,7 @@ shaka.ui.LanguageUtils = class {
shaka.ui.LanguageUtils.getLanguageName(language, localization);
switch (trackLabelFormat) {
case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE:
if (hasDifferentAudioCodecs(language)) {
if (showAudioCodec && hasDifferentAudioCodecs(language)) {
span.textContent += getAudioCodecName(audioCodec);
}
if (showAudioChannelCountVariants) {
Expand All @@ -173,7 +174,7 @@ shaka.ui.LanguageUtils = class {
}
break;
case shaka.ui.Overlay.TrackLabelFormat.ROLE:
if (hasDifferentAudioCodecs(language)) {
if (showAudioCodec && hasDifferentAudioCodecs(language)) {
span.textContent += getAudioCodecName(audioCodec);
}
if (showAudioChannelCountVariants) {
Expand All @@ -192,7 +193,7 @@ shaka.ui.LanguageUtils = class {
}
break;
case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE_ROLE:
if (hasDifferentAudioCodecs(language)) {
if (showAudioCodec && hasDifferentAudioCodecs(language)) {
span.textContent += getAudioCodecName(audioCodec);
}
if (showAudioChannelCountVariants) {
Expand Down
3 changes: 2 additions & 1 deletion ui/text_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu {
this.currentSelection,
this.localization,
this.controls.getConfig().textTrackLabelFormat,
this.controls.getConfig().showAudioChannelCountVariants);
this.controls.getConfig().showAudioChannelCountVariants,
this.controls.getConfig().showAudioCodec);

// Add the Off button
const offButton = shaka.util.Dom.createButton();
Expand Down
1 change: 1 addition & 0 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ shaka.ui.Overlay = class {
defaultVrProjectionMode: 'equirectangular',
setupMediaSession: true,
preferVideoFullScreenInVisionOS: false,
showAudioCodec: true,
};

// eslint-disable-next-line no-restricted-syntax
Expand Down
Loading