mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #4296 from Bnyro/master
fix: fullscreen orientation after shorts video
This commit is contained in:
commit
24210a1eb3
@ -510,6 +510,21 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
NavigationHelper.startAudioPlayer(requireContext())
|
NavigationHelper.startAudioPlayer(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, determine the orientation o use based on the video's aspect ratio
|
||||||
|
* Expected behavior: Portrait for shorts, Landscape for normal videos
|
||||||
|
*/
|
||||||
|
private fun updateFullscreenOrientation() {
|
||||||
|
if (!PlayerHelper.autoRotationEnabled) {
|
||||||
|
val height = streams.videoStreams.firstOrNull()?.height ?: exoPlayer.videoSize.height
|
||||||
|
val width = streams.videoStreams.firstOrNull()?.width ?: exoPlayer.videoSize.width
|
||||||
|
|
||||||
|
// different orientations of the video are only available when autorotation is disabled
|
||||||
|
val orientation = PlayerHelper.getOrientation(width, height)
|
||||||
|
mainActivity.requestedOrientation = orientation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setFullscreen() {
|
private fun setFullscreen() {
|
||||||
with(binding.playerMotionLayout) {
|
with(binding.playerMotionLayout) {
|
||||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
||||||
@ -525,14 +540,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
||||||
playerBinding.exoTitle.visibility = View.VISIBLE
|
playerBinding.exoTitle.visibility = View.VISIBLE
|
||||||
|
|
||||||
if (!PlayerHelper.autoRotationEnabled) {
|
updateFullscreenOrientation()
|
||||||
val height = streams.videoStreams.firstOrNull()?.height ?: exoPlayer.videoSize.height
|
|
||||||
val width = streams.videoStreams.firstOrNull()?.width ?: exoPlayer.videoSize.width
|
|
||||||
|
|
||||||
// different orientations of the video are only available when autorotation is disabled
|
|
||||||
val orientation = PlayerHelper.getOrientation(width, height)
|
|
||||||
mainActivity.requestedOrientation = orientation
|
|
||||||
}
|
|
||||||
|
|
||||||
viewModel.isFullscreen.value = true
|
viewModel.isFullscreen.value = true
|
||||||
}
|
}
|
||||||
@ -746,6 +754,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
prepareExoPlayerView()
|
prepareExoPlayerView()
|
||||||
initializePlayerView()
|
initializePlayerView()
|
||||||
setupSeekbarPreview()
|
setupSeekbarPreview()
|
||||||
|
updateFullscreenOrientation()
|
||||||
|
|
||||||
exoPlayer.prepare()
|
exoPlayer.prepare()
|
||||||
if (PreferenceHelper.getBoolean(PreferenceKeys.PLAY_AUTOMATICALLY, true)) {
|
if (PreferenceHelper.getBoolean(PreferenceKeys.PLAY_AUTOMATICALLY, true)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user