mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 00:20:32 +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:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
- master
|
- master
|
||||||
|
- release/**
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'README.md'
|
- 'README.md'
|
||||||
- 'doc/**'
|
- 'doc/**'
|
||||||
|
@ -3557,15 +3557,27 @@ public final class Player implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apply caption language from previous user preference
|
// apply caption language from previous user preference
|
||||||
final List<String> selectedPreferredLanguages =
|
final int textRendererIndex = getCaptionRendererIndex();
|
||||||
trackSelector.getParameters().preferredTextLanguages;
|
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) {
|
||||||
|
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||||
|
.setRendererDisabled(textRendererIndex, true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (userPreferredLanguage != null
|
// Only set preferred language if it does not match the user preference,
|
||||||
&& !selectedPreferredLanguages.contains(userPreferredLanguage)
|
// otherwise there might be an infinite cycle at onTextTracksChanged.
|
||||||
&& textRendererIndex != RENDERER_UNAVAILABLE) {
|
final List<String> selectedPreferredLanguages =
|
||||||
|
trackSelector.getParameters().preferredTextLanguages;
|
||||||
|
if (!selectedPreferredLanguages.contains(userPreferredLanguage)) {
|
||||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||||
.setPreferredTextLanguages(userPreferredLanguage,
|
.setPreferredTextLanguages(userPreferredLanguage,
|
||||||
PlayerHelper.captionLanguageStemOf(userPreferredLanguage))
|
PlayerHelper.captionLanguageStemOf(userPreferredLanguage))
|
||||||
|
Loading…
Reference in New Issue
Block a user