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