Skip to content

Commit 7f788cd

Browse files
committed
Open fullscreen when switching from popup to main player
1 parent 976f098 commit 7f788cd

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void onServiceConnected(final Player connectedPlayer,
241241
&& isAutoplayEnabled()
242242
&& player.getParentActivity() == null)) {
243243
autoPlayEnabled = true; // forcefully start playing
244-
openVideoPlayer(true);
244+
openVideoPlayerAutoFullscreen();
245245
}
246246
}
247247

@@ -499,7 +499,7 @@ public void onClick(final View v) {
499499
break;
500500
case R.id.detail_thumbnail_root_layout:
501501
autoPlayEnabled = true; // forcefully start playing
502-
openVideoPlayer(true);
502+
openVideoPlayerAutoFullscreen();
503503
break;
504504
case R.id.detail_title_root_layout:
505505
toggleTitleAndSecondaryControls();
@@ -899,7 +899,7 @@ private void runWorker(final boolean forceLoad, final boolean addToBackStack) {
899899
}
900900

901901
if (isAutoplayEnabled()) {
902-
openVideoPlayer(true);
902+
openVideoPlayerAutoFullscreen();
903903
}
904904
}
905905
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_STREAM,
@@ -1105,8 +1105,9 @@ private void openPopupPlayer(final boolean append) {
11051105
}
11061106

11071107
public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
1108+
// Toggle to landscape orientation (which will then cause fullscreen mode) if we are not
1109+
// already in landscape and screen orientation is locked.
11081110
if (directlyFullscreenIfApplicable
1109-
&& PlayerHelper.isStartMainPlayerFullscreen(requireContext())
11101111
&& !DeviceUtils.isLandscape(requireContext())
11111112
&& PlayerHelper.globalScreenOrientationLocked(requireContext())) {
11121113
// Make sure the bottom sheet turns out expanded. When this code kicks in the bottom
@@ -1129,6 +1130,12 @@ public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
11291130
}
11301131
}
11311132

1133+
public void openVideoPlayerAutoFullscreen() {
1134+
// if the option to start directly fullscreen is enabled, openVideoPlayer will be called
1135+
// with directlyFullscreenIfApplicable=true and therefore open fullscreen if applicable
1136+
openVideoPlayer(PlayerHelper.isStartMainPlayerFullscreen(requireContext()));
1137+
}
1138+
11321139
private void openNormalBackgroundPlayer(final boolean append) {
11331140
// See UI changes while remote playQueue changes
11341141
if (!isPlayerAvailable()) {

app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ public static void openVideoDetailFragment(@NonNull final Context context,
366366
if (switchingPlayers) {
367367
// Situation when user switches from players to main player. All needed data is
368368
// here, we can start watching (assuming newQueue equals playQueue).
369-
detailFragment.openVideoPlayer(true);
369+
// Starting directly in fullscreen if the previous player type was popup.
370+
detailFragment.openVideoPlayer(playerType == MainPlayer.PlayerType.POPUP
371+
|| PlayerHelper.isStartMainPlayerFullscreen(context));
370372
} else {
371373
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
372374
}

0 commit comments

Comments
 (0)