diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index da76a4b15b2..29a94fd0f79 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -205,6 +205,7 @@ public final class VideoDetailFragment int lastStableBottomSheetState = BottomSheetBehavior.STATE_EXPANDED; @State protected boolean autoPlayEnabled = true; + private boolean forceFullscreen = false; @Nullable private StreamInfo currentInfo = null; @@ -877,7 +878,7 @@ private void runWorker(final boolean forceLoad, final boolean addToBackStack) { } } - if (isAutoplayEnabled()) { + if (isAutoplayEnabled() || forceFullscreen) { openVideoPlayerAutoFullscreen(); } } @@ -1142,7 +1143,18 @@ public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) { * = false}, hence preventing it from going directly fullscreen. */ public void openVideoPlayerAutoFullscreen() { - openVideoPlayer(PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext())); + openVideoPlayer(forceFullscreen + || PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext())); + forceFullscreen = false; + } + + public void setForceFullscreen(final boolean force) { + this.forceFullscreen = force; + } + + @Nullable + public String getUrl() { + return url; } private void openNormalBackgroundPlayer(final boolean append) { diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index bfdf6a02cdf..9632b9bee30 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.util; import static android.text.TextUtils.isEmpty; +import android.text.TextUtils; import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams; import android.annotation.SuppressLint; @@ -430,13 +431,16 @@ public static void openVideoDetailFragment(@NonNull final Context context, final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = detailFragment -> { expandMainPlayer(detailFragment.requireActivity()); detailFragment.setAutoPlay(autoPlay); - if (switchingPlayers) { + if (switchingPlayers && TextUtils.equals(detailFragment.getUrl(), url)) { // Situation when user switches from players to main player. All needed data is // here, we can start watching (assuming newQueue equals playQueue). // Starting directly in fullscreen if the previous player type was popup. detailFragment.openVideoPlayer(playerType == PlayerType.POPUP || PlayerHelper.isStartMainPlayerFullscreenEnabled(context)); } else { + if (switchingPlayers && playerType == PlayerType.POPUP) { + detailFragment.setForceFullscreen(true); + } detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue); } detailFragment.scrollToTop();