mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
commit
5f702da866
@ -340,9 +340,7 @@ class PlayerFragment : Fragment() {
|
||||
val fullscreenOrientationPref = PreferenceHelper
|
||||
.getString(requireContext(), "fullscreen_orientation", "ratio")
|
||||
|
||||
val scaleFactor = 1.3F
|
||||
playerBinding.exoPlayPause.scaleX = scaleFactor
|
||||
playerBinding.exoPlayPause.scaleY = scaleFactor
|
||||
scaleControls(1.3F)
|
||||
|
||||
val orientation = when (fullscreenOrientationPref) {
|
||||
"ratio" -> {
|
||||
@ -375,9 +373,7 @@ class PlayerFragment : Fragment() {
|
||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen)
|
||||
playerBinding.exoTitle.visibility = View.INVISIBLE
|
||||
|
||||
val scaleFactor = 1F
|
||||
playerBinding.exoPlayPause.scaleX = scaleFactor
|
||||
playerBinding.exoPlayPause.scaleY = scaleFactor
|
||||
scaleControls(1F)
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
@ -385,6 +381,11 @@ class PlayerFragment : Fragment() {
|
||||
isFullScreen = false
|
||||
}
|
||||
|
||||
private fun scaleControls(scaleFactor: Float) {
|
||||
playerBinding.exoPlayPause.scaleX = scaleFactor
|
||||
playerBinding.exoPlayPause.scaleY = scaleFactor
|
||||
}
|
||||
|
||||
private fun toggleComments() {
|
||||
binding.commentsRecView.visibility =
|
||||
if (binding.commentsRecView.isVisible) View.GONE else View.VISIBLE
|
||||
@ -903,6 +904,12 @@ class PlayerFragment : Fragment() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun disableDoubleTapToSeek() {
|
||||
// disable fast forward and rewind by double tapping
|
||||
binding.forwardFL.visibility = View.GONE
|
||||
binding.rewindFL.visibility = View.GONE
|
||||
}
|
||||
|
||||
// toggle the visibility of the player controller
|
||||
private fun toggleController() {
|
||||
if (exoPlayerView.isControllerFullyVisible) exoPlayerView.hideController()
|
||||
@ -1147,11 +1154,15 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
private fun lockPlayer(isLocked: Boolean) {
|
||||
val visibility = if (isLocked) View.VISIBLE else View.GONE
|
||||
|
||||
playerBinding.exoTopBarRight.visibility = visibility
|
||||
playerBinding.exoPlayPause.visibility = visibility
|
||||
playerBinding.exoBottomBar.visibility = visibility
|
||||
playerBinding.closeImageButton.visibility = visibility
|
||||
playerBinding.exoTitle.visibility = visibility
|
||||
|
||||
// disable double tap to seek when the player is locked
|
||||
if (isLocked) enableDoubleTapToSeek() else disableDoubleTapToSeek()
|
||||
}
|
||||
|
||||
private fun isSubscribed(button: MaterialButton, channel_id: String) {
|
||||
@ -1305,28 +1316,29 @@ class PlayerFragment : Fragment() {
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode)
|
||||
if (isInPictureInPictureMode) {
|
||||
// hide and disable exoPlayer controls
|
||||
exoPlayerView.hideController()
|
||||
exoPlayerView.useController = false
|
||||
|
||||
// hide anything but the player
|
||||
binding.linLayout.visibility = View.GONE
|
||||
binding.mainContainer.isClickable = true
|
||||
|
||||
with(binding.playerMotionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
||||
enableTransition(R.id.yt_transition, false)
|
||||
}
|
||||
binding.mainContainer.isClickable = true
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
|
||||
isFullScreen = false
|
||||
} else {
|
||||
with(binding.playerMotionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
enableTransition(R.id.yt_transition, true)
|
||||
}
|
||||
|
||||
// enable exoPlayer controls again
|
||||
exoPlayerView.useController = true
|
||||
binding.linLayout.visibility = View.VISIBLE
|
||||
binding.mainContainer.isClickable = false
|
||||
|
||||
// switch back to portrait mode
|
||||
unsetFullscreen()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutDescription="@xml/activity_main_scene"
|
||||
tools:context=".MainActivity">
|
||||
tools:context=".activities.MainActivity">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
@ -363,43 +363,58 @@
|
||||
app:layout_constraintTop_toTopOf="@id/main_container"
|
||||
app:show_buffering="when_playing">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardFL"
|
||||
android:layout_width="wrap_content"
|
||||
<!-- double tap to rewind/forward overlay -->
|
||||
<LinearLayout
|
||||
android:id="@+id/doubleTapOverlayLL"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:layout_marginVertical="50dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/forwardBTN"
|
||||
android:layout_width="150dp"
|
||||
<!-- double tap rewind btn -->
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindFL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:clickable="false"
|
||||
android:src="@drawable/ic_forward"
|
||||
android:visibility="invisible"
|
||||
app:tint="@android:color/white" />
|
||||
android:layout_weight=".40">
|
||||
|
||||
</FrameLayout>
|
||||
<ImageButton
|
||||
android:id="@+id/rewindBTN"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:clickable="false"
|
||||
android:src="@drawable/ic_rewind"
|
||||
android:visibility="invisible"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindFL"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:layout_marginVertical="50dp">
|
||||
</FrameLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/rewindBTN"
|
||||
android:layout_width="150dp"
|
||||
<!-- place holder for the center controls -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:clickable="false"
|
||||
android:src="@drawable/ic_rewind"
|
||||
android:visibility="invisible"
|
||||
app:tint="@android:color/white" />
|
||||
android:layout_weight=".20" />
|
||||
|
||||
</FrameLayout>
|
||||
<!-- double tap forward btn -->
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardFL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".40">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/forwardBTN"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:clickable="false"
|
||||
android:src="@drawable/ic_forward"
|
||||
android:visibility="invisible"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.github.libretube.views.CustomExoPlayerView>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user