Rename useVideoSource to useVideoAndSubtitles in Player

As both subtitles and video tracks are disabled in this method, the
goal of this rename is to highlight disabling/enabled subtitles.
This commit is contained in:
AudricV 2025-07-05 20:48:49 +02:00 committed by Stypox
parent c670ad80ee
commit 0578e7fde0
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
3 changed files with 10 additions and 9 deletions

View File

@ -2195,12 +2195,12 @@ public final class Player implements PlaybackListener, Listener {
}
}
public void useVideoSource(final boolean videoEnabled) {
public void useVideoAndSubtitles(final boolean videoAndSubtitlesEnabled) {
if (playQueue == null || audioPlayerSelected()) {
return;
}
isAudioOnly = !videoEnabled;
isAudioOnly = !videoAndSubtitlesEnabled;
getCurrentStreamInfo().ifPresentOrElse(info -> {
// In case we don't know the source type, fall back to either video-with-audio, or
@ -2214,10 +2214,11 @@ public final class Player implements PlaybackListener, Listener {
setRecovery();
// Disable or enable video and subtitles renderers depending of the videoEnabled value
// Disable or enable video and subtitles renderers depending of the
// videoAndSubtitlesEnabled value
trackSelector.setParameters(trackSelector.buildUponParameters()
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoEnabled)
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoEnabled));
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoAndSubtitlesEnabled)
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoAndSubtitlesEnabled));
}, () -> {
/*
The current metadata may be null sometimes (for e.g. when using an unstable connection

View File

@ -331,7 +331,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
} else if (VideoDetailFragment.ACTION_VIDEO_FRAGMENT_RESUMED.equals(intent.getAction())) {
// Restore video source when user returns to the fragment
fragmentIsVisible = true;
player.useVideoSource(true);
player.useVideoAndSubtitles(true);
// When a user returns from background, the system UI will always be shown even if
// controls are invisible: hide it in that case
@ -370,7 +370,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
if (player.isPlaying() || player.isLoading()) {
switch (getMinimizeOnExitAction(context)) {
case MINIMIZE_ON_EXIT_MODE_BACKGROUND:
player.useVideoSource(false);
player.useVideoAndSubtitles(false);
break;
case MINIMIZE_ON_EXIT_MODE_POPUP:
getParentActivity().ifPresent(activity -> {

View File

@ -219,10 +219,10 @@ public final class PopupPlayerUi extends VideoPlayerUi {
} else if (player.isPlaying() || player.isLoading()) {
if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
// Use only audio source when screen turns off while popup player is playing
player.useVideoSource(false);
player.useVideoAndSubtitles(false);
} else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
// Restore video source when screen turns on and user was watching video in popup
player.useVideoSource(true);
player.useVideoAndSubtitles(true);
}
}
}