diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 358f011d1..f400815a5 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -284,7 +284,22 @@ class PlayerFragment : Fragment() { scaleFactor = 1.3F val mainActivity = activity as MainActivity - mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + val fullscreenOrientationPref = PreferenceHelper + .getString(requireContext(), "fullscreen_rotation", "ratio") + val orientation = when(fullscreenOrientationPref) { + "ratio" -> { + val videoSize = exoPlayer.videoSize + // probably a youtube shorts video + if (videoSize.height > videoSize.width) ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT + // a video with normal aspect ratio + else ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + } + "auto" -> ActivityInfo.SCREEN_ORIENTATION_USER + "landscape" -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + "portrait" -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT + else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + } + mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT } else { // leave fullscreen mode with(binding.playerMotionLayout) { @@ -1214,7 +1229,7 @@ class PlayerFragment : Fragment() { enableTransition(R.id.yt_transition, false) } binding.mainContainer.isClickable = true - + val mainActivity = activity as MainActivity mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT isFullScreen = false diff --git a/app/src/main/res/drawable/ic_fullscreen.xml b/app/src/main/res/drawable/ic_fullscreen.xml index bf4ff36cd..ad9f6dfec 100644 --- a/app/src/main/res/drawable/ic_fullscreen.xml +++ b/app/src/main/res/drawable/ic_fullscreen.xml @@ -1,7 +1,7 @@ 30 + + @string/aspect_ratio + @string/auto_rotation + @string/landscape + @string/portrait + + + ratio + auto + landscape + portrait + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 16f5c7da0..0cc5687a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -143,7 +143,7 @@ You are running the latest version. Default playback speed Advanced - Audio and video + Player Adjust the app to your liking. Downloads, history Live @@ -215,4 +215,10 @@ Choose an auth instance Auto GitHub + Audio and video + Fullscreen orientation + Video aspect ratio + Auto rotation + Landscape + Portrait \ No newline at end of file diff --git a/app/src/main/res/xml/player_settings.xml b/app/src/main/res/xml/player_settings.xml index b7f9ed9a9..54e72029b 100644 --- a/app/src/main/res/xml/player_settings.xml +++ b/app/src/main/res/xml/player_settings.xml @@ -24,7 +24,7 @@ - + + + + + + + \ No newline at end of file