small improvements

This commit is contained in:
Bnyro 2022-07-04 21:30:13 +02:00
parent 73beffef22
commit e0147cbaad

View File

@ -285,11 +285,13 @@ class PlayerFragment : Fragment() {
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
val fullscreenOrientationPref = PreferenceHelper val fullscreenOrientationPref = PreferenceHelper
.getString(requireContext(), "fullscreen_rotation", "ratio") .getString(requireContext(), "fullscreen_orientation", "ratio")
val orientation = when(fullscreenOrientationPref) { Log.e(TAG, fullscreenOrientationPref.toString())
val orientation = when (fullscreenOrientationPref) {
"ratio" -> { "ratio" -> {
val videoSize = exoPlayer.videoSize val videoSize = exoPlayer.videoSize
// probably a youtube shorts video // probably a youtube shorts video
Log.e(TAG, videoSize.height.toString() + " " + videoSize.width.toString())
if (videoSize.height > videoSize.width) ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT if (videoSize.height > videoSize.width) ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
// a video with normal aspect ratio // a video with normal aspect ratio
else ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE else ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
@ -299,7 +301,7 @@ class PlayerFragment : Fragment() {
"portrait" -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT "portrait" -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
} }
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT mainActivity.requestedOrientation = orientation
} else { } else {
// leave fullscreen mode // leave fullscreen mode
with(binding.playerMotionLayout) { with(binding.playerMotionLayout) {