Skip to content

Commit a0848f7

Browse files
authored
fix(UI): Show Dolby Atmos name in the UI (shaka-project#7848)
1 parent ae35e9b commit a0848f7

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

ui/language_utils.js

+20-21
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ shaka.ui.LanguageUtils = class {
7878
};
7979

8080
const getCombination = (language, rolesString, label, channelsCount,
81-
audioCodec) => {
81+
audioCodec, spatialAudio) => {
8282
const keys = [
8383
language,
8484
rolesString,
85+
spatialAudio,
8586
];
8687
if (showAudioChannelCountVariants && channelsCount != null) {
8788
keys.push(channelsCount);
@@ -136,7 +137,7 @@ shaka.ui.LanguageUtils = class {
136137
const selectedCombination = selectedTrack ? getCombination(
137138
selectedTrack.language, getRolesString(selectedTrack),
138139
selectedTrack.label, selectedTrack.channelsCount,
139-
selectedTrack.audioCodec) : '';
140+
selectedTrack.audioCodec, selectedTrack.spatialAudio) : '';
140141

141142
for (const track of tracks) {
142143
const language = track.language;
@@ -146,9 +147,10 @@ shaka.ui.LanguageUtils = class {
146147
const label = track.label;
147148
const channelsCount = track.channelsCount;
148149
const audioCodec = track.audioCodec;
150+
const spatialAudio = track.spatialAudio;
149151
const combinationName =
150152
getCombination(language, rolesString, label, channelsCount,
151-
audioCodec);
153+
audioCodec, spatialAudio);
152154
if (combinationsMade.has(combinationName)) {
153155
continue;
154156
}
@@ -164,25 +166,27 @@ shaka.ui.LanguageUtils = class {
164166

165167
span.textContent =
166168
shaka.ui.LanguageUtils.getLanguageName(language, localization);
169+
let basicInfo = '';
170+
if (showAudioCodec && showAudioChannelCountVariants &&
171+
spatialAudio && audioCodec == 'ec-3') {
172+
basicInfo += ' Dolby Atmos';
173+
} else {
174+
if (showAudioCodec && hasDifferentAudioCodecs(language)) {
175+
basicInfo += getAudioCodecName(audioCodec);
176+
}
177+
if (showAudioChannelCountVariants) {
178+
basicInfo += getChannelsCountName(channelsCount);
179+
}
180+
}
167181
switch (trackLabelFormat) {
168182
case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE:
169-
if (showAudioCodec && hasDifferentAudioCodecs(language)) {
170-
span.textContent += getAudioCodecName(audioCodec);
171-
}
172-
if (showAudioChannelCountVariants) {
173-
span.textContent += getChannelsCountName(channelsCount);
174-
}
183+
span.textContent += basicInfo;
175184
if (forced) {
176185
span.textContent += ' (' + forcedString + ')';
177186
}
178187
break;
179188
case shaka.ui.Overlay.TrackLabelFormat.ROLE:
180-
if (showAudioCodec && hasDifferentAudioCodecs(language)) {
181-
span.textContent += getAudioCodecName(audioCodec);
182-
}
183-
if (showAudioChannelCountVariants) {
184-
span.textContent += getChannelsCountName(channelsCount);
185-
}
189+
span.textContent += basicInfo;
186190
if (!rolesString) {
187191
// Fallback behavior. This probably shouldn't happen.
188192
shaka.log.alwaysWarn('Track #' + track.id + ' does not have a ' +
@@ -196,12 +200,7 @@ shaka.ui.LanguageUtils = class {
196200
}
197201
break;
198202
case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE_ROLE:
199-
if (showAudioCodec && hasDifferentAudioCodecs(language)) {
200-
span.textContent += getAudioCodecName(audioCodec);
201-
}
202-
if (showAudioChannelCountVariants) {
203-
span.textContent += getChannelsCountName(channelsCount);
204-
}
203+
span.textContent += basicInfo;
205204
if (rolesString) {
206205
span.textContent += ': ' + rolesString;
207206
}

0 commit comments

Comments
 (0)