Fix for wrong case after language normalization

This commit is contained in:
Robin 2019-03-06 09:37:55 +01:00
parent 7f246b2d3d
commit a2aa0aa9a8

View file

@ -509,11 +509,11 @@ public abstract class VideoPlayer extends BasePlayer
// Normalize mismatching language strings // Normalize mismatching language strings
final String preferredLanguage = trackSelector.getParameters().preferredTextLanguage; final String preferredLanguage = trackSelector.getParameters().preferredTextLanguage;
// Build UI // Build UI
buildCaptionMenu(availableLanguages); buildCaptionMenu(availableLanguages);
if (trackSelector.getParameters().getRendererDisabled(textRenderer) || if (trackSelector.getParameters().getRendererDisabled(textRenderer) ||
preferredLanguage == null || !availableLanguages.contains(preferredLanguage)) { preferredLanguage == null || (!availableLanguages.contains(preferredLanguage)
&& !containsCaseInsensitive(availableLanguages, preferredLanguage))) {
captionTextView.setText(R.string.caption_none); captionTextView.setText(R.string.caption_none);
} else { } else {
captionTextView.setText(preferredLanguage); captionTextView.setText(preferredLanguage);
@ -521,6 +521,15 @@ public abstract class VideoPlayer extends BasePlayer
captionTextView.setVisibility(availableLanguages.isEmpty() ? View.GONE : View.VISIBLE); captionTextView.setVisibility(availableLanguages.isEmpty() ? View.GONE : View.VISIBLE);
} }
// workaround to match normalized captions like english to English or deutsch to Deutsch
private static boolean containsCaseInsensitive(List<String> list, String toFind) {
for(String i : list){
if(i.equalsIgnoreCase(toFind))
return true;
}
return false;
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// General Player // General Player
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/