Skip to content

Commit 70dad9b

Browse files
committed
Fix video playback when exiting popup to fullscreen
Fix for the issue ( #6400 ) wrong video plays when exiting popup mode to fullscreen.
1 parent c169232 commit 70dad9b

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public final class VideoDetailFragment
205205
int lastStableBottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
206206
@State
207207
protected boolean autoPlayEnabled = true;
208+
private boolean forceFullscreen = false;
208209

209210
@Nullable
210211
private StreamInfo currentInfo = null;
@@ -877,7 +878,7 @@ private void runWorker(final boolean forceLoad, final boolean addToBackStack) {
877878
}
878879
}
879880

880-
if (isAutoplayEnabled()) {
881+
if (isAutoplayEnabled() || forceFullscreen) {
881882
openVideoPlayerAutoFullscreen();
882883
}
883884
}
@@ -1142,7 +1143,18 @@ public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
11421143
* = false}, hence preventing it from going directly fullscreen.
11431144
*/
11441145
public void openVideoPlayerAutoFullscreen() {
1145-
openVideoPlayer(PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext()));
1146+
openVideoPlayer(forceFullscreen || PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext()));
1147+
forceFullscreen = false;
1148+
}
1149+
1150+
public void setForceFullscreen(final boolean force) {
1151+
this.forceFullscreen = force;
1152+
}
1153+
1154+
//return the URL of the stream currently handled by this fragment.
1155+
@Nullable
1156+
public String getUrl() {
1157+
return url;
11461158
}
11471159

11481160
private void openNormalBackgroundPlayer(final boolean append) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.schabi.newpipe.util;
22

33
import static android.text.TextUtils.isEmpty;
4+
import android.text.TextUtils;
45
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
56

67
import android.annotation.SuppressLint;
@@ -430,13 +431,16 @@ public static void openVideoDetailFragment(@NonNull final Context context,
430431
final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = detailFragment -> {
431432
expandMainPlayer(detailFragment.requireActivity());
432433
detailFragment.setAutoPlay(autoPlay);
433-
if (switchingPlayers) {
434+
if (switchingPlayers && TextUtils.equals(detailFragment.getUrl(), url)) {
434435
// Situation when user switches from players to main player. All needed data is
435436
// here, we can start watching (assuming newQueue equals playQueue).
436437
// Starting directly in fullscreen if the previous player type was popup.
437438
detailFragment.openVideoPlayer(playerType == PlayerType.POPUP
438439
|| PlayerHelper.isStartMainPlayerFullscreenEnabled(context));
439440
} else {
441+
if (switchingPlayers && playerType == PlayerType.POPUP) {
442+
detailFragment.setForceFullscreen(true);
443+
}
440444
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
441445
}
442446
detailFragment.scrollToTop();

0 commit comments

Comments
 (0)