mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Fix top margin when viewing video in vertical fullscreen
This commit is contained in:
parent
9cd1fd9d58
commit
b33ecff67e
@ -396,7 +396,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
}
|
||||
|
||||
// FullScreen button trigger
|
||||
// hide fullscreen button if auto rotation enabled
|
||||
// hide fullscreen button if autorotation enabled
|
||||
playerBinding.fullscreen.isInvisible = PlayerHelper.autoRotationEnabled
|
||||
playerBinding.fullscreen.setOnClickListener {
|
||||
// hide player controller
|
||||
@ -508,7 +508,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
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 auto rotation is disabled
|
||||
// different orientations of the video are only available when autorotation is disabled
|
||||
val orientation = PlayerHelper.getOrientation(width, height)
|
||||
mainActivity.requestedOrientation = orientation
|
||||
}
|
||||
@ -538,7 +538,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
playerBinding.exoTitle.visibility = View.INVISIBLE
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -237,13 +237,18 @@ class PlaylistFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun showPlaylistVideos(playlist: Playlist) {
|
||||
val videos = if (playlistType == PlaylistType.PUBLIC) playlistFeed
|
||||
else {
|
||||
val videos = if (playlistType == PlaylistType.PUBLIC) {
|
||||
playlistFeed
|
||||
} else {
|
||||
when (selectedSortOrder) {
|
||||
0, 1 -> {
|
||||
if (playlistType == PlaylistType.LOCAL) playlistFeed.sortedBy {
|
||||
it.url.orEmpty().toInt()
|
||||
} else playlistFeed
|
||||
if (playlistType == PlaylistType.LOCAL) {
|
||||
playlistFeed.sortedBy {
|
||||
it.url.orEmpty().toInt()
|
||||
}
|
||||
} else {
|
||||
playlistFeed
|
||||
}
|
||||
}
|
||||
2, 3 -> {
|
||||
playlistFeed.sortedBy { it.duration }
|
||||
|
@ -219,6 +219,7 @@ internal class CustomExoPlayerView(
|
||||
|
||||
playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { 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
|
||||
*/
|
||||
private fun updateTopBarMargin() {
|
||||
val isFullscreen =
|
||||
resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE ||
|
||||
playerViewModel?.isFullscreen?.value == true
|
||||
val margin = when {
|
||||
resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE -> 10
|
||||
playerViewModel?.isFullscreen?.value == true -> 20
|
||||
else -> 0
|
||||
}
|
||||
binding.topBar.updateLayoutParams<MarginLayoutParams> {
|
||||
topMargin = (if (isFullscreen) 10 else 0).dpToPx().toInt()
|
||||
topMargin = margin.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user