Another fix of VideoDetailFragment

This commit is contained in:
Avently 2020-01-13 19:24:28 +03:00
parent 421b8214cb
commit 0c394b123c
1 changed files with 7 additions and 15 deletions

View File

@ -112,7 +112,6 @@ public class VideoDetailFragment
public static final String ACTION_SHOW_MAIN_PLAYER = "org.schabi.newpipe.fragments.VideoDetailFragment.ACTION_SHOW_MAIN_PLAYER"; public static final String ACTION_SHOW_MAIN_PLAYER = "org.schabi.newpipe.fragments.VideoDetailFragment.ACTION_SHOW_MAIN_PLAYER";
public static final String ACTION_HIDE_MAIN_PLAYER = "org.schabi.newpipe.fragments.VideoDetailFragment.ACTION_HIDE_MAIN_PLAYER"; public static final String ACTION_HIDE_MAIN_PLAYER = "org.schabi.newpipe.fragments.VideoDetailFragment.ACTION_HIDE_MAIN_PLAYER";
private boolean autoPlayEnabled;
private boolean showRelatedStreams; private boolean showRelatedStreams;
private boolean showComments; private boolean showComments;
private String selectedTabTag; private String selectedTabTag;
@ -127,6 +126,8 @@ public class VideoDetailFragment
protected PlayQueue playQueue; protected PlayQueue playQueue;
@State @State
int bottomSheetState = BottomSheetBehavior.STATE_EXPANDED; int bottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
@State
protected boolean autoPlayEnabled = true;
private StreamInfo currentInfo; private StreamInfo currentInfo;
private Disposable currentWorker; private Disposable currentWorker;
@ -311,9 +312,6 @@ public class VideoDetailFragment
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setHasOptionsMenu(true); setHasOptionsMenu(true);
// Let's play all streams automatically
setAutoplay(true);
activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
showRelatedStreams = PreferenceManager.getDefaultSharedPreferences(activity) showRelatedStreams = PreferenceManager.getDefaultSharedPreferences(activity)
@ -870,6 +868,7 @@ public class VideoDetailFragment
if (player != null && player.isInFullscreen()) { if (player != null && player.isInFullscreen()) {
player.onPause(); player.onPause();
restoreDefaultOrientation(); restoreDefaultOrientation();
setAutoplay(false);
return true; return true;
} }
@ -1169,8 +1168,7 @@ public class VideoDetailFragment
// This method overrides default behaviour when setAutoplay() is called. // This method overrides default behaviour when setAutoplay() is called.
// Don't auto play if the user selected an external player or disabled it in settings // Don't auto play if the user selected an external player or disabled it in settings
private boolean isAutoplayEnabled() { private boolean isAutoplayEnabled() {
return playQueue != null && playQueue.getStreams().size() != 0 return autoPlayEnabled
&& autoPlayEnabled
&& !isExternalPlayerEnabled() && !isExternalPlayerEnabled()
&& (player == null || player.videoPlayerSelected()) && (player == null || player.videoPlayerSelected())
&& isAutoplayAllowedByUser(); && isAutoplayAllowedByUser();
@ -1326,22 +1324,16 @@ public class VideoDetailFragment
if (player != null && player.isInFullscreen()) player.toggleFullscreen(); if (player != null && player.isInFullscreen()) player.toggleFullscreen();
// This will show systemUI and pause the player. // This will show systemUI and pause the player.
// User can tap on Play button and video will be in fullscreen mode again // User can tap on Play button and video will be in fullscreen mode again
if (globalScreenOrientationLocked()) removeVideoPlayerView();
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} }
private void setupOrientation() { private void setupOrientation() {
if (player == null || !player.videoPlayerSelected() || activity == null) return; if (player == null || !player.videoPlayerSelected() || activity == null) return;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
int newOrientation; int newOrientation;
if (globalScreenOrientationLocked()) { if (globalScreenOrientationLocked())
boolean lastOrientationWasLandscape newOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
= sharedPreferences.getBoolean(getString(R.string.last_orientation_landscape_key), false); else
newOrientation = lastOrientationWasLandscape
? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
: ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
} else
newOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; newOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
if (newOrientation != activity.getRequestedOrientation()) if (newOrientation != activity.getRequestedOrientation())