Skip to content

Commit e4a3185

Browse files
committed
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.
1 parent 1929785 commit e4a3185

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,12 +2095,12 @@ private void notifyAudioTrackUpdateToListeners() {
20952095
}
20962096
}
20972097

2098-
public void useVideoSource(final boolean videoEnabled) {
2098+
public void useVideoAndSubtitles(final boolean videoAndSubtitlesEnabled) {
20992099
if (playQueue == null || audioPlayerSelected()) {
21002100
return;
21012101
}
21022102

2103-
isAudioOnly = !videoEnabled;
2103+
isAudioOnly = !videoAndSubtitlesEnabled;
21042104

21052105
getCurrentStreamInfo().ifPresentOrElse(info -> {
21062106
// In case we don't know the source type, fall back to either video-with-audio, or
@@ -2114,10 +2114,11 @@ public void useVideoSource(final boolean videoEnabled) {
21142114

21152115
setRecovery();
21162116

2117-
// Disable or enable video and subtitles renderers depending of the videoEnabled value
2117+
// Disable or enable video and subtitles renderers depending of the
2118+
// videoAndSubtitlesEnabled value
21182119
trackSelector.setParameters(trackSelector.buildUponParameters()
2119-
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoEnabled)
2120-
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoEnabled));
2120+
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoAndSubtitlesEnabled)
2121+
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoAndSubtitlesEnabled));
21212122
}, () -> {
21222123
/*
21232124
The current metadata may be null sometimes (for e.g. when using an unstable connection

app/src/main/java/org/schabi/newpipe/player/ui/MainPlayerUi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public void onBroadcastReceived(final Intent intent) {
329329
} else if (VideoDetailFragment.ACTION_VIDEO_FRAGMENT_RESUMED.equals(intent.getAction())) {
330330
// Restore video source when user returns to the fragment
331331
fragmentIsVisible = true;
332-
player.useVideoSource(true);
332+
player.useVideoAndSubtitles(true);
333333

334334
// When a user returns from background, the system UI will always be shown even if
335335
// controls are invisible: hide it in that case
@@ -368,7 +368,7 @@ private void onFragmentStopped() {
368368
if (player.isPlaying() || player.isLoading()) {
369369
switch (getMinimizeOnExitAction(context)) {
370370
case MINIMIZE_ON_EXIT_MODE_BACKGROUND:
371-
player.useVideoSource(false);
371+
player.useVideoAndSubtitles(false);
372372
break;
373373
case MINIMIZE_ON_EXIT_MODE_POPUP:
374374
getParentActivity().ifPresent(activity -> {

app/src/main/java/org/schabi/newpipe/player/ui/PopupPlayerUi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ public void onBroadcastReceived(final Intent intent) {
216216
} else if (player.isPlaying() || player.isLoading()) {
217217
if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
218218
// Use only audio source when screen turns off while popup player is playing
219-
player.useVideoSource(false);
219+
player.useVideoAndSubtitles(false);
220220
} else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
221221
// Restore video source when screen turns on and user was watching video in popup
222-
player.useVideoSource(true);
222+
player.useVideoAndSubtitles(true);
223223
}
224224
}
225225
}

0 commit comments

Comments
 (0)