1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Add option to directly open fullscreen when the main player starts

This commit is contained in:
Stypox 2021-01-19 08:13:44 +01:00
parent faa7a91764
commit 3c2ea7697c
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
7 changed files with 44 additions and 12 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -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);

View File

@ -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);
}

View File

@ -73,6 +73,8 @@
<item>@string/minimize_on_exit_popup_description</item>
</string-array>
<string name="start_main_player_fullscreen_key" translatable="false">start_main_player_fullscreen_key</string>
<string name="autoplay_key" translatable="false">autoplay_key</string>
<string name="autoplay_value" translatable="false">@string/autoplay_wifi_key</string>
<string name="autoplay_always_key" translatable="false">autoplay_always_key</string>

View File

@ -132,6 +132,8 @@
<string name="resume_on_audio_focus_gain_title">Resume playing</string>
<string name="resume_on_audio_focus_gain_summary">Continue playing after interruptions (e.g. phonecalls)</string>
<string name="download_dialog_title">Download</string>
<string name="start_main_player_fullscreen_title">Start main player in fullscreen</string>
<string name="start_main_player_fullscreen_summary">Do not start videos in the mini player, but turn to fullscreen mode directly, if auto rotation is locked. You can still access the mini player by exiting fullscreen.</string>
<string name="autoplay_title">Autoplay</string>
<string name="show_hold_to_append_title">Show \"Hold to append\" tip</string>
<string name="show_hold_to_append_summary">Show tip when pressing the background or the popup button in video \"Details:\"</string>

View File

@ -129,6 +129,14 @@
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="@string/start_main_player_fullscreen_key"
android:summary="@string/start_main_player_fullscreen_summary"
android:title="@string/start_main_player_fullscreen_title"
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="@string/autoplay_value"
android:entries="@array/autoplay_type_description"