From 44ca4cbbaade6fb14ec86e648aa0d29bc4069c14 Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Tue, 7 Feb 2023 21:41:24 +0530 Subject: [PATCH 1/3] Made improvement to player double-tap further. --- .../libretube/ui/views/CustomExoPlayerView.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index bc46f7f9c0..7d402f3b4c 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -8,6 +8,7 @@ import android.graphics.Color import android.os.Handler import android.os.Looper import android.util.AttributeSet +import android.util.Log import android.view.MotionEvent import android.view.View import android.widget.FrameLayout @@ -118,6 +119,8 @@ internal class CustomExoPlayerView( // don't let the player view hide its controls automatically controllerShowTimeoutMs = -1 + // don't let the player view show its controls automatically + controllerAutoShow = false // locking the player binding.lockPlayer.setOnClickListener { @@ -172,6 +175,11 @@ internal class CustomExoPlayerView( // keep screen on if the video is playing keepScreenOn = player.isPlaying == true + + if (player.playbackState == Player.STATE_ENDED && !autoplayEnabled) { + showController() + cancelHideControllerTask() + } } } }) @@ -603,8 +611,9 @@ 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 isFullscreen = + resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || + playerViewModel?.isFullscreen?.value == true binding.topBar.updateLayoutParams { topMargin = (if (isFullscreen) 10 else 0).dpToPx().toInt() } @@ -615,6 +624,7 @@ internal class CustomExoPlayerView( } override fun onDoubleTapCenterScreen() { + Log.d("LibreTubeTags", "onDoubleTapCenterScreen") player?.let { player -> if (player.isPlaying) { player.pause() From c8c214d9befd7ee90af5db8e68dcf08f22487a03 Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Tue, 7 Feb 2023 21:45:13 +0530 Subject: [PATCH 2/3] Minor fixes. --- .../java/com/github/libretube/ui/views/CustomExoPlayerView.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 7d402f3b4c..cf0e1328f4 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -624,7 +624,6 @@ internal class CustomExoPlayerView( } override fun onDoubleTapCenterScreen() { - Log.d("LibreTubeTags", "onDoubleTapCenterScreen") player?.let { player -> if (player.isPlaying) { player.pause() From 274f523b7f5201790aa8ef2525a059562cf5d46c Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Tue, 7 Feb 2023 21:47:11 +0530 Subject: [PATCH 3/3] fix ktlint --- .../java/com/github/libretube/ui/views/CustomExoPlayerView.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index cf0e1328f4..557442136e 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -8,7 +8,6 @@ import android.graphics.Color import android.os.Handler import android.os.Looper import android.util.AttributeSet -import android.util.Log import android.view.MotionEvent import android.view.View import android.widget.FrameLayout @@ -613,7 +612,7 @@ internal class CustomExoPlayerView( private fun updateTopBarMargin() { val isFullscreen = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || - playerViewModel?.isFullscreen?.value == true + playerViewModel?.isFullscreen?.value == true binding.topBar.updateLayoutParams { topMargin = (if (isFullscreen) 10 else 0).dpToPx().toInt() }