mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-04-15 11:21:23 +00:00
Add option to directly open fullscreen when the main player starts
This commit is contained in:
@@ -241,7 +241,7 @@ public final class VideoDetailFragment
|
||||
&& isAutoplayEnabled()
|
||||
&& player.getParentActivity() == null)) {
|
||||
autoPlayEnabled = true; // forcefully start playing
|
||||
openVideoPlayer();
|
||||
openVideoPlayer(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ public final class VideoDetailFragment
|
||||
break;
|
||||
case R.id.detail_thumbnail_root_layout:
|
||||
autoPlayEnabled = true; // forcefully start playing
|
||||
openVideoPlayer();
|
||||
openVideoPlayer(true);
|
||||
break;
|
||||
case R.id.detail_title_root_layout:
|
||||
toggleTitleAndSecondaryControls();
|
||||
@@ -516,7 +516,7 @@ public final class VideoDetailFragment
|
||||
showSystemUi();
|
||||
} else {
|
||||
autoPlayEnabled = true; // forcefully start playing
|
||||
openVideoPlayer();
|
||||
openVideoPlayer(false);
|
||||
}
|
||||
|
||||
setOverlayPlayPauseImage(isPlayerAvailable() && player.isPlaying());
|
||||
@@ -897,8 +897,9 @@ public final class VideoDetailFragment
|
||||
stack.push(new StackItem(serviceId, url, title, playQueue));
|
||||
}
|
||||
}
|
||||
|
||||
if (isAutoplayEnabled()) {
|
||||
openVideoPlayer();
|
||||
openVideoPlayer(true);
|
||||
}
|
||||
}
|
||||
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_STREAM,
|
||||
@@ -1103,7 +1104,15 @@ public final class VideoDetailFragment
|
||||
}
|
||||
}
|
||||
|
||||
public void openVideoPlayer() {
|
||||
public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
|
||||
if (directlyFullscreenIfApplicable
|
||||
&& PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext())
|
||||
&& !isLandscape()
|
||||
&& PlayerHelper.globalScreenOrientationLocked(requireContext())) {
|
||||
// open directly in fullscreen TODO does it work for large-land layouts?
|
||||
onScreenRotationButtonClicked();
|
||||
}
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
|
||||
showExternalPlaybackDialog();
|
||||
@@ -1145,8 +1154,8 @@ public final class VideoDetailFragment
|
||||
}
|
||||
addVideoPlayerView();
|
||||
|
||||
final Intent playerIntent = NavigationHelper
|
||||
.getPlayerIntent(requireContext(), MainPlayer.class, queue, true, autoPlayEnabled);
|
||||
final Intent playerIntent = NavigationHelper.getPlayerIntent(requireContext(),
|
||||
MainPlayer.class, queue, true, autoPlayEnabled);
|
||||
ContextCompat.startForegroundService(activity, playerIntent);
|
||||
}
|
||||
|
||||
@@ -2022,7 +2031,7 @@ public final class VideoDetailFragment
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLandscape() {
|
||||
public boolean isLandscape() {
|
||||
return getResources().getDisplayMetrics().heightPixels < getResources()
|
||||
.getDisplayMetrics().widthPixels;
|
||||
}
|
||||
|
||||
@@ -3855,11 +3855,9 @@ public final class Player implements
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "toggleFullscreen() called");
|
||||
}
|
||||
if (popupPlayerSelected() || exoPlayerIsNull() || currentMetadata == null
|
||||
|| fragmentListener == null) {
|
||||
if (popupPlayerSelected() || exoPlayerIsNull() || fragmentListener == null) {
|
||||
return;
|
||||
}
|
||||
//changeState(STATE_BLOCKED); TODO check what this does
|
||||
|
||||
isFullscreen = !isFullscreen;
|
||||
if (!isFullscreen) {
|
||||
|
||||
@@ -239,6 +239,11 @@ public final class PlayerHelper {
|
||||
.getBoolean(context.getString(R.string.brightness_gesture_control_key), true);
|
||||
}
|
||||
|
||||
public static boolean isStartMainPlayerFullscreenEnabled(@NonNull final Context context) {
|
||||
return getPreferences(context)
|
||||
.getBoolean(context.getString(R.string.start_main_player_fullscreen_key), false);
|
||||
}
|
||||
|
||||
public static boolean isAutoQueueEnabled(@NonNull final Context context) {
|
||||
return getPreferences(context)
|
||||
.getBoolean(context.getString(R.string.auto_queue_key), false);
|
||||
|
||||
@@ -366,7 +366,15 @@ public final class NavigationHelper {
|
||||
if (switchingPlayers) {
|
||||
// Situation when user switches from players to main player. All needed data is
|
||||
// here, we can start watching (assuming newQueue equals playQueue).
|
||||
detailFragment.openVideoPlayer();
|
||||
|
||||
// Starting directly in fullscreen if the previous player type was popup.
|
||||
if (playerType == MainPlayer.PlayerType.POPUP
|
||||
&& !detailFragment.isLandscape()
|
||||
&& PlayerHelper.globalScreenOrientationLocked(context)) {
|
||||
detailFragment.onScreenRotationButtonClicked();
|
||||
}
|
||||
// pass false to directlyFullscreenIfApplicable since that's handled just above here
|
||||
detailFragment.openVideoPlayer(false);
|
||||
} else {
|
||||
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user