Add option to directly open fullscreen when the main player starts
This commit is contained in:
parent
faa7a91764
commit
3c2ea7697c
|
@ -241,7 +241,7 @@ public final class VideoDetailFragment
|
||||||
&& isAutoplayEnabled()
|
&& isAutoplayEnabled()
|
||||||
&& player.getParentActivity() == null)) {
|
&& player.getParentActivity() == null)) {
|
||||||
autoPlayEnabled = true; // forcefully start playing
|
autoPlayEnabled = true; // forcefully start playing
|
||||||
openVideoPlayer();
|
openVideoPlayer(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ public final class VideoDetailFragment
|
||||||
break;
|
break;
|
||||||
case R.id.detail_thumbnail_root_layout:
|
case R.id.detail_thumbnail_root_layout:
|
||||||
autoPlayEnabled = true; // forcefully start playing
|
autoPlayEnabled = true; // forcefully start playing
|
||||||
openVideoPlayer();
|
openVideoPlayer(true);
|
||||||
break;
|
break;
|
||||||
case R.id.detail_title_root_layout:
|
case R.id.detail_title_root_layout:
|
||||||
toggleTitleAndSecondaryControls();
|
toggleTitleAndSecondaryControls();
|
||||||
|
@ -516,7 +516,7 @@ public final class VideoDetailFragment
|
||||||
showSystemUi();
|
showSystemUi();
|
||||||
} else {
|
} else {
|
||||||
autoPlayEnabled = true; // forcefully start playing
|
autoPlayEnabled = true; // forcefully start playing
|
||||||
openVideoPlayer();
|
openVideoPlayer(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setOverlayPlayPauseImage(isPlayerAvailable() && player.isPlaying());
|
setOverlayPlayPauseImage(isPlayerAvailable() && player.isPlaying());
|
||||||
|
@ -897,8 +897,9 @@ public final class VideoDetailFragment
|
||||||
stack.push(new StackItem(serviceId, url, title, playQueue));
|
stack.push(new StackItem(serviceId, url, title, playQueue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAutoplayEnabled()) {
|
if (isAutoplayEnabled()) {
|
||||||
openVideoPlayer();
|
openVideoPlayer(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_STREAM,
|
}, 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)
|
if (PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
|
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
|
||||||
showExternalPlaybackDialog();
|
showExternalPlaybackDialog();
|
||||||
|
@ -1145,8 +1154,8 @@ public final class VideoDetailFragment
|
||||||
}
|
}
|
||||||
addVideoPlayerView();
|
addVideoPlayerView();
|
||||||
|
|
||||||
final Intent playerIntent = NavigationHelper
|
final Intent playerIntent = NavigationHelper.getPlayerIntent(requireContext(),
|
||||||
.getPlayerIntent(requireContext(), MainPlayer.class, queue, true, autoPlayEnabled);
|
MainPlayer.class, queue, true, autoPlayEnabled);
|
||||||
ContextCompat.startForegroundService(activity, playerIntent);
|
ContextCompat.startForegroundService(activity, playerIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2022,7 +2031,7 @@ public final class VideoDetailFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLandscape() {
|
public boolean isLandscape() {
|
||||||
return getResources().getDisplayMetrics().heightPixels < getResources()
|
return getResources().getDisplayMetrics().heightPixels < getResources()
|
||||||
.getDisplayMetrics().widthPixels;
|
.getDisplayMetrics().widthPixels;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3855,11 +3855,9 @@ public final class Player implements
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "toggleFullscreen() called");
|
Log.d(TAG, "toggleFullscreen() called");
|
||||||
}
|
}
|
||||||
if (popupPlayerSelected() || exoPlayerIsNull() || currentMetadata == null
|
if (popupPlayerSelected() || exoPlayerIsNull() || fragmentListener == null) {
|
||||||
|| fragmentListener == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//changeState(STATE_BLOCKED); TODO check what this does
|
|
||||||
|
|
||||||
isFullscreen = !isFullscreen;
|
isFullscreen = !isFullscreen;
|
||||||
if (!isFullscreen) {
|
if (!isFullscreen) {
|
||||||
|
|
|
@ -239,6 +239,11 @@ public final class PlayerHelper {
|
||||||
.getBoolean(context.getString(R.string.brightness_gesture_control_key), true);
|
.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) {
|
public static boolean isAutoQueueEnabled(@NonNull final Context context) {
|
||||||
return getPreferences(context)
|
return getPreferences(context)
|
||||||
.getBoolean(context.getString(R.string.auto_queue_key), false);
|
.getBoolean(context.getString(R.string.auto_queue_key), false);
|
||||||
|
|
|
@ -366,7 +366,15 @@ public final class NavigationHelper {
|
||||||
if (switchingPlayers) {
|
if (switchingPlayers) {
|
||||||
// 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).
|
||||||
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 {
|
} else {
|
||||||
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
|
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,8 @@
|
||||||
<item>@string/minimize_on_exit_popup_description</item>
|
<item>@string/minimize_on_exit_popup_description</item>
|
||||||
</string-array>
|
</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_key" translatable="false">autoplay_key</string>
|
||||||
<string name="autoplay_value" translatable="false">@string/autoplay_wifi_key</string>
|
<string name="autoplay_value" translatable="false">@string/autoplay_wifi_key</string>
|
||||||
<string name="autoplay_always_key" translatable="false">autoplay_always_key</string>
|
<string name="autoplay_always_key" translatable="false">autoplay_always_key</string>
|
||||||
|
|
|
@ -132,6 +132,8 @@
|
||||||
<string name="resume_on_audio_focus_gain_title">Resume playing</string>
|
<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="resume_on_audio_focus_gain_summary">Continue playing after interruptions (e.g. phonecalls)</string>
|
||||||
<string name="download_dialog_title">Download</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="autoplay_title">Autoplay</string>
|
||||||
<string name="show_hold_to_append_title">Show \"Hold to append\" tip</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>
|
<string name="show_hold_to_append_summary">Show tip when pressing the background or the popup button in video \"Details:\"</string>
|
||||||
|
|
|
@ -129,6 +129,14 @@
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:iconSpaceReserved="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
|
<ListPreference
|
||||||
android:defaultValue="@string/autoplay_value"
|
android:defaultValue="@string/autoplay_value"
|
||||||
android:entries="@array/autoplay_type_description"
|
android:entries="@array/autoplay_type_description"
|
||||||
|
|
Loading…
Reference in New Issue