Fix video playback when exiting popup to main screen (#13437)
Fix for the issue ( #6400 ) wrong video plays when exiting popup mode to fullscreen.
This commit is contained in:
parent
1abc484e5e
commit
4de3071f76
2 changed files with 28 additions and 9 deletions
|
|
@ -205,6 +205,7 @@ public final class VideoDetailFragment
|
||||||
int lastStableBottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
|
int lastStableBottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
|
||||||
@State
|
@State
|
||||||
protected boolean autoPlayEnabled = true;
|
protected boolean autoPlayEnabled = true;
|
||||||
|
private boolean forceFullscreen = false;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private StreamInfo currentInfo = null;
|
private StreamInfo currentInfo = null;
|
||||||
|
|
@ -877,7 +878,7 @@ public final class VideoDetailFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAutoplayEnabled()) {
|
if (isAutoplayEnabled() || forceFullscreen) {
|
||||||
openVideoPlayerAutoFullscreen();
|
openVideoPlayerAutoFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1134,15 +1135,29 @@ public final class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the option to start directly fullscreen is enabled, calls
|
* If the option to start directly fullscreen is enabled, or if {@code forceFullscreen} is
|
||||||
* {@link #openVideoPlayer(boolean)} with {@code directlyFullscreenIfApplicable = true}, so that
|
* {@code true} (e.g. when switching from popup player to main player with a different video),
|
||||||
* if the user is not already in landscape and he has screen orientation locked the activity
|
* calls {@link #openVideoPlayer(boolean)} with {@code directlyFullscreenIfApplicable = true},
|
||||||
* rotates and fullscreen starts. Otherwise, if the option to start directly fullscreen is
|
* so that if the user is not already in landscape and he has screen orientation locked the
|
||||||
* disabled, calls {@link #openVideoPlayer(boolean)} with {@code directlyFullscreenIfApplicable
|
* activity rotates and fullscreen starts. Otherwise, if the option to start directly fullscreen
|
||||||
* = false}, hence preventing it from going directly fullscreen.
|
* is disabled and {@code forceFullscreen} is {@code false}, calls
|
||||||
|
* {@link #openVideoPlayer(boolean)} with {@code directlyFullscreenIfApplicable = false},
|
||||||
|
* hence preventing it from going directly fullscreen.
|
||||||
|
* {@code forceFullscreen} is reset to {@code false} after this call.
|
||||||
*/
|
*/
|
||||||
public void openVideoPlayerAutoFullscreen() {
|
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) {
|
private void openNormalBackgroundPlayer(final boolean append) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
import static android.text.TextUtils.isEmpty;
|
import static android.text.TextUtils.isEmpty;
|
||||||
|
import android.text.TextUtils;
|
||||||
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
|
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
|
@ -430,13 +431,16 @@ public final class NavigationHelper {
|
||||||
final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = detailFragment -> {
|
final RunnableWithVideoDetailFragment onVideoDetailFragmentReady = detailFragment -> {
|
||||||
expandMainPlayer(detailFragment.requireActivity());
|
expandMainPlayer(detailFragment.requireActivity());
|
||||||
detailFragment.setAutoPlay(autoPlay);
|
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
|
// Situation when user switches from players to main player. All needed data is
|
||||||
// here, we can start watching (assuming newQueue equals playQueue).
|
// here, we can start watching (assuming newQueue equals playQueue).
|
||||||
// Starting directly in fullscreen if the previous player type was popup.
|
// Starting directly in fullscreen if the previous player type was popup.
|
||||||
detailFragment.openVideoPlayer(playerType == PlayerType.POPUP
|
detailFragment.openVideoPlayer(playerType == PlayerType.POPUP
|
||||||
|| PlayerHelper.isStartMainPlayerFullscreenEnabled(context));
|
|| PlayerHelper.isStartMainPlayerFullscreenEnabled(context));
|
||||||
} else {
|
} else {
|
||||||
|
if (switchingPlayers && playerType == PlayerType.POPUP) {
|
||||||
|
detailFragment.setForceFullscreen(true);
|
||||||
|
}
|
||||||
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
|
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
|
||||||
}
|
}
|
||||||
detailFragment.scrollToTop();
|
detailFragment.scrollToTop();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue