fixed: added comments for DefaultTrackSelector auto-select fix.
This commit is contained in:
parent
4917da2d2e
commit
29fc0eff38
|
@ -3557,20 +3557,27 @@ public final class Player implements
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply caption language from previous user preference
|
// apply caption language from previous user preference
|
||||||
|
final int textRendererIndex = getCaptionRendererIndex();
|
||||||
|
if (textRendererIndex == RENDERER_UNAVAILABLE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If user prefers to show no caption, then disable the renderer.
|
||||||
|
// Otherwise, DefaultTrackSelector may automatically find an available caption
|
||||||
|
// and display that.
|
||||||
final String userPreferredLanguage =
|
final String userPreferredLanguage =
|
||||||
prefs.getString(context.getString(R.string.caption_user_set_key), null);
|
prefs.getString(context.getString(R.string.caption_user_set_key), null);
|
||||||
final int textRendererIndex = getCaptionRendererIndex();
|
|
||||||
|
|
||||||
if (userPreferredLanguage == null) {
|
if (userPreferredLanguage == null) {
|
||||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||||
.setRendererDisabled(textRendererIndex, true));
|
.setRendererDisabled(textRendererIndex, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only set preferred language if it does not match the user preference,
|
||||||
|
// otherwise there might be an infinite cycle at onTextTracksChanged.
|
||||||
final List<String> selectedPreferredLanguages =
|
final List<String> selectedPreferredLanguages =
|
||||||
trackSelector.getParameters().preferredTextLanguages;
|
trackSelector.getParameters().preferredTextLanguages;
|
||||||
if (!selectedPreferredLanguages.contains(userPreferredLanguage)
|
if (!selectedPreferredLanguages.contains(userPreferredLanguage)) {
|
||||||
&& textRendererIndex != RENDERER_UNAVAILABLE) {
|
|
||||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||||
.setPreferredTextLanguages(userPreferredLanguage,
|
.setPreferredTextLanguages(userPreferredLanguage,
|
||||||
PlayerHelper.captionLanguageStemOf(userPreferredLanguage))
|
PlayerHelper.captionLanguageStemOf(userPreferredLanguage))
|
||||||
|
|
Loading…
Reference in New Issue