Fix top margin when viewing video in vertical fullscreen

This commit is contained in:
Bnyro 2023-04-27 20:24:15 +02:00
parent 9cd1fd9d58
commit b33ecff67e
3 changed files with 20 additions and 12 deletions

View File

@ -396,7 +396,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
} }
// FullScreen button trigger // FullScreen button trigger
// hide fullscreen button if auto rotation enabled // hide fullscreen button if autorotation enabled
playerBinding.fullscreen.isInvisible = PlayerHelper.autoRotationEnabled playerBinding.fullscreen.isInvisible = PlayerHelper.autoRotationEnabled
playerBinding.fullscreen.setOnClickListener { playerBinding.fullscreen.setOnClickListener {
// hide player controller // hide player controller
@ -508,7 +508,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
val height = streams.videoStreams.firstOrNull()?.height ?: exoPlayer.videoSize.height val height = streams.videoStreams.firstOrNull()?.height ?: exoPlayer.videoSize.height
val width = streams.videoStreams.firstOrNull()?.width ?: exoPlayer.videoSize.width val width = streams.videoStreams.firstOrNull()?.width ?: exoPlayer.videoSize.width
// different orientations of the video are only available when auto rotation is disabled // different orientations of the video are only available when autorotation is disabled
val orientation = PlayerHelper.getOrientation(width, height) val orientation = PlayerHelper.getOrientation(width, height)
mainActivity.requestedOrientation = orientation mainActivity.requestedOrientation = orientation
} }
@ -538,7 +538,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
playerBinding.exoTitle.visibility = View.INVISIBLE playerBinding.exoTitle.visibility = View.INVISIBLE
if (!PlayerHelper.autoRotationEnabled) { if (!PlayerHelper.autoRotationEnabled) {
// switch back to portrait mode if auto rotation disabled // switch back to portrait mode if autorotation disabled
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
} }

View File

@ -237,13 +237,18 @@ class PlaylistFragment : Fragment() {
} }
private fun showPlaylistVideos(playlist: Playlist) { private fun showPlaylistVideos(playlist: Playlist) {
val videos = if (playlistType == PlaylistType.PUBLIC) playlistFeed val videos = if (playlistType == PlaylistType.PUBLIC) {
else { playlistFeed
} else {
when (selectedSortOrder) { when (selectedSortOrder) {
0, 1 -> { 0, 1 -> {
if (playlistType == PlaylistType.LOCAL) playlistFeed.sortedBy { if (playlistType == PlaylistType.LOCAL) {
it.url.orEmpty().toInt() playlistFeed.sortedBy {
} else playlistFeed it.url.orEmpty().toInt()
}
} else {
playlistFeed
}
} }
2, 3 -> { 2, 3 -> {
playlistFeed.sortedBy { it.duration } playlistFeed.sortedBy { it.duration }

View File

@ -219,6 +219,7 @@ internal class CustomExoPlayerView(
playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen -> playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen ->
WindowHelper.toggleFullscreen(activity, isFullscreen) WindowHelper.toggleFullscreen(activity, isFullscreen)
updateTopBarMargin()
} }
} }
@ -644,11 +645,13 @@ internal class CustomExoPlayerView(
* Add extra margin to the top bar to not overlap the status bar * Add extra margin to the top bar to not overlap the status bar
*/ */
private fun updateTopBarMargin() { private fun updateTopBarMargin() {
val isFullscreen = val margin = when {
resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE -> 10
playerViewModel?.isFullscreen?.value == true playerViewModel?.isFullscreen?.value == true -> 20
else -> 0
}
binding.topBar.updateLayoutParams<MarginLayoutParams> { binding.topBar.updateLayoutParams<MarginLayoutParams> {
topMargin = (if (isFullscreen) 10 else 0).dpToPx().toInt() topMargin = margin.dpToPx().toInt()
} }
} }