Skip to content

Commit

Permalink
Fix rotation when when auto-rotate is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbox87 committed Sep 11, 2020
1 parent 530f745 commit 5fd26a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1421,13 +1421,6 @@ private void restoreDefaultOrientation() {
if (player != null && player.isFullscreen()) {
player.toggleFullscreen();
}
// This will show systemUI and pause the player.
// User can tap on Play button and video will be in fullscreen mode again
// Note for tablet: trying to avoid orientation changes since it's not easy
// to physically rotate the tablet every time
if (!DeviceUtils.isTablet(activity)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1937,6 +1930,11 @@ public void onScreenRotationButtonClicked() {
return;
}

if (isLandscape() && PlayerHelper.globalScreenOrientationLocked(activity)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
return;
}

final int newOrientation = isLandscape()
? ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,15 @@ public void toggleFullscreen() {
return;
}

// This makes the button function correctly if you disable auto-rotate
// while watching a vertical video and your phones in landscape
final boolean orientationLocked = PlayerHelper.globalScreenOrientationLocked(service);
final boolean isTablet = DeviceUtils.isTablet(service);
if (orientationLocked && isFullscreen && service.isLandscape() && !isTablet) {
fragmentListener.onScreenRotationButtonClicked();
return;
}

isFullscreen = !isFullscreen;
setControlsSize();
fragmentListener.onFullscreenStateChanged(isFullscreen());
Expand Down

0 comments on commit 5fd26a2

Please sign in to comment.