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 8edbc1b8d9
commit 85bb37368d
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()) { if (playQueue == null || audioPlayerSelected()) {
return; return;
} }
isAudioOnly = !videoEnabled; isAudioOnly = !videoAndSubtitlesEnabled;
getCurrentStreamInfo().ifPresentOrElse(info -> { getCurrentStreamInfo().ifPresentOrElse(info -> {
// In case we don't know the source type, fall back to either video-with-audio, or // 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(); 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() trackSelector.setParameters(trackSelector.buildUponParameters()
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoEnabled) .setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoAndSubtitlesEnabled)
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoEnabled)); .setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoAndSubtitlesEnabled));
}, () -> { }, () -> {
/* /*
The current metadata may be null sometimes (for e.g. when using an unstable connection 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())) { } else if (VideoDetailFragment.ACTION_VIDEO_FRAGMENT_RESUMED.equals(intent.getAction())) {
// Restore video source when user returns to the fragment // Restore video source when user returns to the fragment
fragmentIsVisible = true; fragmentIsVisible = true;
player.useVideoSource(true); player.useVideoAndSubtitles(true);
// When a user returns from background, the system UI will always be shown even if // When a user returns from background, the system UI will always be shown even if
// controls are invisible: hide it in that case // 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()) { if (player.isPlaying() || player.isLoading()) {
switch (getMinimizeOnExitAction(context)) { switch (getMinimizeOnExitAction(context)) {
case MINIMIZE_ON_EXIT_MODE_BACKGROUND: case MINIMIZE_ON_EXIT_MODE_BACKGROUND:
player.useVideoSource(false); player.useVideoAndSubtitles(false);
break; break;
case MINIMIZE_ON_EXIT_MODE_POPUP: case MINIMIZE_ON_EXIT_MODE_POPUP:
getParentActivity().ifPresent(activity -> { getParentActivity().ifPresent(activity -> {

View file

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