Skip to content

Commit

Permalink
Open fullscreen when switching from popup to main player
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Aug 26, 2021
1 parent 976f098 commit 7f788cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void onServiceConnected(final Player connectedPlayer,
&& isAutoplayEnabled()
&& player.getParentActivity() == null)) {
autoPlayEnabled = true; // forcefully start playing
openVideoPlayer(true);
openVideoPlayerAutoFullscreen();
}
}

Expand Down Expand Up @@ -499,7 +499,7 @@ public void onClick(final View v) {
break;
case R.id.detail_thumbnail_root_layout:
autoPlayEnabled = true; // forcefully start playing
openVideoPlayer(true);
openVideoPlayerAutoFullscreen();
break;
case R.id.detail_title_root_layout:
toggleTitleAndSecondaryControls();
Expand Down Expand Up @@ -899,7 +899,7 @@ private void runWorker(final boolean forceLoad, final boolean addToBackStack) {
}

if (isAutoplayEnabled()) {
openVideoPlayer(true);
openVideoPlayerAutoFullscreen();
}
}
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_STREAM,
Expand Down Expand Up @@ -1105,8 +1105,9 @@ private void openPopupPlayer(final boolean append) {
}

public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
// Toggle to landscape orientation (which will then cause fullscreen mode) if we are not
// already in landscape and screen orientation is locked.
if (directlyFullscreenIfApplicable
&& PlayerHelper.isStartMainPlayerFullscreen(requireContext())
&& !DeviceUtils.isLandscape(requireContext())
&& PlayerHelper.globalScreenOrientationLocked(requireContext())) {
// Make sure the bottom sheet turns out expanded. When this code kicks in the bottom
Expand All @@ -1129,6 +1130,12 @@ public void openVideoPlayer(final boolean directlyFullscreenIfApplicable) {
}
}

public void openVideoPlayerAutoFullscreen() {
// if the option to start directly fullscreen is enabled, openVideoPlayer will be called
// with directlyFullscreenIfApplicable=true and therefore open fullscreen if applicable
openVideoPlayer(PlayerHelper.isStartMainPlayerFullscreen(requireContext()));
}

private void openNormalBackgroundPlayer(final boolean append) {
// See UI changes while remote playQueue changes
if (!isPlayerAvailable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ public static void openVideoDetailFragment(@NonNull final Context context,
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(true);
// Starting directly in fullscreen if the previous player type was popup.
detailFragment.openVideoPlayer(playerType == MainPlayer.PlayerType.POPUP
|| PlayerHelper.isStartMainPlayerFullscreen(context));
} else {
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
}
Expand Down

0 comments on commit 7f788cd

Please sign in to comment.