mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-22 16:10:31 +00:00
Merge pull request #8249 from karyogamy/caption-fix-2
Fix disabled caption to no longer automatically re-enable on new player instance
This commit is contained in:
commit
31df4e42d7
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -6,6 +6,7 @@ on:
|
||||
branches:
|
||||
- dev
|
||||
- master
|
||||
- release/**
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
@ -3557,15 +3557,27 @@ public final class Player implements
|
||||
}
|
||||
|
||||
// apply caption language from previous user preference
|
||||
final List<String> selectedPreferredLanguages =
|
||||
trackSelector.getParameters().preferredTextLanguages;
|
||||
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 =
|
||||
prefs.getString(context.getString(R.string.caption_user_set_key), null);
|
||||
final int textRendererIndex = getCaptionRendererIndex();
|
||||
if (userPreferredLanguage == null) {
|
||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||
.setRendererDisabled(textRendererIndex, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (userPreferredLanguage != null
|
||||
&& !selectedPreferredLanguages.contains(userPreferredLanguage)
|
||||
&& textRendererIndex != RENDERER_UNAVAILABLE) {
|
||||
// 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 =
|
||||
trackSelector.getParameters().preferredTextLanguages;
|
||||
if (!selectedPreferredLanguages.contains(userPreferredLanguage)) {
|
||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||
.setPreferredTextLanguages(userPreferredLanguage,
|
||||
PlayerHelper.captionLanguageStemOf(userPreferredLanguage))
|
||||
|
Loading…
Reference in New Issue
Block a user