Skip to content

Commit

Permalink
fix(UI): Fix text selector when the trackLabelFormat is set to LABEL (#…
Browse files Browse the repository at this point in the history
…5751)

Fixes #5747
  • Loading branch information
avelad authored Oct 9, 2023
1 parent de17603 commit bba0651
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ui/language_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ shaka.ui.LanguageUtils = class {
}
};

const getCombination = (language, rolesString) => {
const getCombination = (language, rolesString, label) => {
if (label &&
trackLabelFormat == shaka.ui.Overlay.TrackLabelFormat.LABEL) {
return language + ': ' + label + ': ' + rolesString;
}
return language + ': ' + rolesString;
};

Expand All @@ -72,15 +76,17 @@ shaka.ui.LanguageUtils = class {
/** @type {!Set.<string>} */
const combinationsMade = new Set();
const selectedCombination = selectedTrack ? getCombination(
selectedTrack.language, getRolesString(selectedTrack)) : '';
selectedTrack.language, getRolesString(selectedTrack),
selectedTrack.label) : '';

for (const track of tracks) {
const language = track.language;
const forced = track.forced;
const LocIds = shaka.ui.Locales.Ids;
const forcedString = localization.resolve(LocIds.SUBTITLE_FORCED);
const rolesString = getRolesString(track);
const combinationName = getCombination(language, rolesString);
const label = track.label;
const combinationName = getCombination(language, rolesString, label);
if (combinationsMade.has(combinationName)) {
continue;
}
Expand Down Expand Up @@ -124,8 +130,8 @@ shaka.ui.LanguageUtils = class {
}
break;
case shaka.ui.Overlay.TrackLabelFormat.LABEL:
if (track.label) {
span.textContent = track.label;
if (label) {
span.textContent = label;
} else {
// Fallback behavior. This probably shouldn't happen.
shaka.log.alwaysWarn('Track #' + track.id + ' does not have a ' +
Expand Down

0 comments on commit bba0651

Please sign in to comment.