mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50:30 +05:30
commit
a805168c50
@ -270,63 +270,15 @@ class PlayerFragment : Fragment() {
|
|||||||
|
|
||||||
// FullScreen button trigger
|
// FullScreen button trigger
|
||||||
playerBinding.fullscreen.setOnClickListener {
|
playerBinding.fullscreen.setOnClickListener {
|
||||||
|
// hide player controller
|
||||||
exoPlayerView.hideController()
|
exoPlayerView.hideController()
|
||||||
var scaleFactor: Float? = null
|
|
||||||
if (!isFullScreen) {
|
if (!isFullScreen) {
|
||||||
// go to fullscreen mode
|
// go to fullscreen mode
|
||||||
with(binding.playerMotionLayout) {
|
setFullscreen()
|
||||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
|
||||||
enableTransition(R.id.yt_transition, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.mainContainer.isClickable = true
|
|
||||||
binding.linLayout.visibility = View.GONE
|
|
||||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
|
||||||
playerBinding.exoTitle.visibility = View.VISIBLE
|
|
||||||
|
|
||||||
scaleFactor = 1.3F
|
|
||||||
|
|
||||||
val mainActivity = activity as MainActivity
|
|
||||||
val fullscreenOrientationPref = PreferenceHelper
|
|
||||||
.getString(requireContext(), "fullscreen_orientation", "ratio")
|
|
||||||
Log.e(TAG, fullscreenOrientationPref.toString())
|
|
||||||
val orientation = when (fullscreenOrientationPref) {
|
|
||||||
"ratio" -> {
|
|
||||||
val videoSize = exoPlayer.videoSize
|
|
||||||
// probably a youtube shorts video
|
|
||||||
Log.e(TAG, videoSize.height.toString() + " " + videoSize.width.toString())
|
|
||||||
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 = orientation
|
|
||||||
} else {
|
} else {
|
||||||
// leave fullscreen mode
|
// exit fullscreen mode
|
||||||
with(binding.playerMotionLayout) {
|
unsetFullscreen()
|
||||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
|
||||||
enableTransition(R.id.yt_transition, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.mainContainer.isClickable = false
|
|
||||||
binding.linLayout.visibility = View.VISIBLE
|
|
||||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen)
|
|
||||||
playerBinding.exoTitle.visibility = View.INVISIBLE
|
|
||||||
|
|
||||||
scaleFactor = 1F
|
|
||||||
|
|
||||||
val mainActivity = activity as MainActivity
|
|
||||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
|
||||||
}
|
}
|
||||||
isFullScreen = !isFullScreen
|
|
||||||
|
|
||||||
// scale the exo player center controls
|
|
||||||
playerBinding.exoPlayPause.scaleX = scaleFactor
|
|
||||||
playerBinding.exoPlayPause.scaleY = scaleFactor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// switching between original aspect ratio (black bars) and zoomed to fill device screen
|
// switching between original aspect ratio (black bars) and zoomed to fill device screen
|
||||||
@ -373,6 +325,66 @@ class PlayerFragment : Fragment() {
|
|||||||
GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
|
GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setFullscreen() {
|
||||||
|
with(binding.playerMotionLayout) {
|
||||||
|
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
||||||
|
enableTransition(R.id.yt_transition, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.mainContainer.isClickable = true
|
||||||
|
binding.linLayout.visibility = View.GONE
|
||||||
|
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
||||||
|
playerBinding.exoTitle.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
val mainActivity = activity as MainActivity
|
||||||
|
val fullscreenOrientationPref = PreferenceHelper
|
||||||
|
.getString(requireContext(), "fullscreen_orientation", "ratio")
|
||||||
|
|
||||||
|
val scaleFactor = 1.3F
|
||||||
|
playerBinding.exoPlayPause.scaleX = scaleFactor
|
||||||
|
playerBinding.exoPlayPause.scaleY = scaleFactor
|
||||||
|
|
||||||
|
val orientation = when (fullscreenOrientationPref) {
|
||||||
|
"ratio" -> {
|
||||||
|
val videoSize = exoPlayer.videoSize
|
||||||
|
// probably a youtube shorts video
|
||||||
|
Log.e(TAG, videoSize.height.toString() + " " + videoSize.width.toString())
|
||||||
|
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 = orientation
|
||||||
|
|
||||||
|
isFullScreen = true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun unsetFullscreen() {
|
||||||
|
// leave fullscreen mode
|
||||||
|
with(binding.playerMotionLayout) {
|
||||||
|
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||||
|
enableTransition(R.id.yt_transition, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.mainContainer.isClickable = false
|
||||||
|
binding.linLayout.visibility = View.VISIBLE
|
||||||
|
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen)
|
||||||
|
playerBinding.exoTitle.visibility = View.INVISIBLE
|
||||||
|
|
||||||
|
val scaleFactor = 1F
|
||||||
|
playerBinding.exoPlayPause.scaleX = scaleFactor
|
||||||
|
playerBinding.exoPlayPause.scaleY = scaleFactor
|
||||||
|
|
||||||
|
val mainActivity = activity as MainActivity
|
||||||
|
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||||
|
|
||||||
|
isFullScreen = false
|
||||||
|
}
|
||||||
|
|
||||||
private fun toggleComments() {
|
private fun toggleComments() {
|
||||||
binding.commentsRecView.visibility =
|
binding.commentsRecView.visibility =
|
||||||
if (binding.commentsRecView.isVisible) View.GONE else View.VISIBLE
|
if (binding.commentsRecView.isVisible) View.GONE else View.VISIBLE
|
||||||
|
@ -203,9 +203,10 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@id/exo_center_controls"
|
android:id="@id/exo_center_controls"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="@dimen/exo_styled_controls_padding">
|
android:padding="@dimen/exo_styled_controls_padding">
|
||||||
@ -213,6 +214,7 @@
|
|||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@id/exo_play_pause"
|
android:id="@id/exo_play_pause"
|
||||||
style="@style/ExoStyledControls.Button.Center.PlayPause"
|
style="@style/ExoStyledControls.Button.Center.PlayPause"
|
||||||
|
android:background="?android:selectableItemBackgroundBorderless"
|
||||||
app:tint="@android:color/white" />
|
app:tint="@android:color/white" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user