From e4d39cbec406e9b074d2ceadbdd2f0b5d6767b4d Mon Sep 17 00:00:00 2001 From: Koen Date: Thu, 7 Dec 2023 17:16:25 +0100 Subject: [PATCH] Added stop all gestures flow. --- .../mainactivity/main/VideoDetailFragment.kt | 1 + .../fragment/mainactivity/main/VideoDetailView.kt | 13 +++++++++++-- .../views/behavior/GestureControlView.kt | 10 ++++++++++ .../futo/platformplayer/views/casting/CastView.kt | 4 ++++ .../platformplayer/views/video/FutoVideoPlayer.kt | 4 ++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt index 41b8ade7..476acfbb 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt @@ -216,6 +216,7 @@ class VideoDetailFragment : MainFragment { } _view!!.setTransitionListener(object : MotionLayout.TransitionListener { override fun onTransitionChange(motionLayout: MotionLayout?, startId: Int, endId: Int, progress: Float) { + _viewDetail?.stopAllGestures() if (state != State.MINIMIZED && progress < 0.1) { state = State.MINIMIZED; diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt index edb2b381..002a879c 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt @@ -683,6 +683,11 @@ class VideoDetailView : ConstraintLayout { } } + fun stopAllGestures() { + _player.stopAllGestures(); + _cast.stopAllGestures(); + } + fun updateMoreButtons() { val buttons = listOf(RoundButton(context, R.drawable.ic_add, context.getString(R.string.add), TAG_ADD) { (video ?: _searchVideo)?.let { @@ -1941,6 +1946,7 @@ class VideoDetailView : ConstraintLayout { video?.let { updateQualitySourcesOverlay(it, videoLocal); }; + val changed = _isCasting != isCasting; _isCasting = isCasting; if(isCasting) { @@ -1948,8 +1954,7 @@ class VideoDetailView : ConstraintLayout { _player.stop(); _player.hideControls(false); _cast.visibility = View.VISIBLE; - } - else { + } else { StateCasting.instance.stopVideo(); _cast.stopTimeJob(); _cast.visibility = View.GONE; @@ -1958,6 +1963,10 @@ class VideoDetailView : ConstraintLayout { _player.setPlaybackRate(Settings.instance.playback.getDefaultPlaybackSpeed()); } } + + if (changed) { + stopAllGestures(); + } } fun setFullscreen(fullscreen : Boolean) { diff --git a/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt b/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt index 7b33534e..f48cd486 100644 --- a/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt @@ -330,11 +330,21 @@ class GestureControlView : LinearLayout { _controlsVisible = false; } + fun stopAllGestures() { + stopAdjustingFullscreenDown() + stopAdjustingBrightness() + stopAdjustingSound() + stopAdjustingFullscreenUp() + stopFastForward() + stopAutoFastForward() + } + fun cleanup() { _jobExitFastForward?.cancel(); _jobExitFastForward = null; _jobAutoFastForward?.cancel(); _jobAutoFastForward = null; + stopAllGestures(); cancelHideJob(); _scope.cancel(); } diff --git a/app/src/main/java/com/futo/platformplayer/views/casting/CastView.kt b/app/src/main/java/com/futo/platformplayer/views/casting/CastView.kt index 86e762b0..8cbbabbb 100644 --- a/app/src/main/java/com/futo/platformplayer/views/casting/CastView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/casting/CastView.kt @@ -102,6 +102,10 @@ class CastView : ConstraintLayout { _updateTimeJob = null; } + fun stopAllGestures() { + _gestureControlView.stopAllGestures(); + } + fun setIsPlaying(isPlaying: Boolean) { _updateTimeJob?.cancel(); diff --git a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt index f0983299..64533459 100644 --- a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt +++ b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt @@ -343,6 +343,10 @@ class FutoVideoPlayer : FutoVideoPlayerBase { _currentChapterLoopActive = false; } + fun stopAllGestures() { + gestureControl.stopAllGestures(); + } + fun attachPlayer() { exoPlayer?.attach(_videoView, PLAYER_STATE_NAME); }