From b2da6f50806b20fb0c253f5af06845d643b08b0e Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 20 Feb 2020 12:04:16 +0100 Subject: [PATCH] skip by 10s at clicking on the curr/max video durations too --- .../gallery/pro/activities/VideoPlayerActivity.kt | 15 +++++++-------- .../gallery/pro/fragments/VideoFragment.kt | 15 +++++++-------- .../gallery/pro/helpers/Constants.kt | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index 6b08ef6c3..eb13b4cf0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -195,13 +195,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen video_brightness_controller.initialize(this, slide_info, true, video_player_holder, singleTap = { x, y -> toggleFullscreen() }, doubleTap = {x, y -> - doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) + doSkip(false) }) video_volume_controller.initialize(this, slide_info, false, video_player_holder, singleTap = { x, y -> toggleFullscreen() }, doubleTap = {x, y -> - doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) + doSkip(true) }) } else { video_brightness_controller.beGone() @@ -307,8 +307,8 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen private fun handleDoubleTap(x: Float) { val instantWidth = mScreenWidth / 7 when { - x <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) - x >= mScreenWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) + x <= instantWidth -> doSkip(false) + x >= mScreenWidth - instantWidth -> doSkip(true) else -> togglePlayPause() } } @@ -501,13 +501,12 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen return } - val twoPercents = Math.max((mExoPlayer!!.duration / 50).toInt(), MIN_SKIP_LENGTH) - doSkip(twoPercents, forward) + doSkip(forward) } - private fun doSkip(millis: Int, forward: Boolean) { + private fun doSkip(forward: Boolean) { val curr = mExoPlayer!!.currentPosition - val newProgress = if (forward) curr + millis else curr - millis + val newProgress = if (forward) curr + FAST_FORWARD_VIDEO_MS else curr - FAST_FORWARD_VIDEO_MS val roundProgress = Math.round(newProgress / 1000f) val limitedProgress = Math.max(Math.min(mExoPlayer!!.duration.toInt() / 1000, roundProgress), 0) setPosition(limitedProgress) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index 8d7557fd3..ab8f93529 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -207,7 +207,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S toggleFullscreen() } }, doubleTap = {x, y -> - doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) + doSkip(false) }) mVolumeSideScroll.initialize(activity!!, slide_info, false, container, singleTap = { x, y -> @@ -217,7 +217,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S toggleFullscreen() } }, doubleTap = {x, y -> - doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) + doSkip(true) }) video_surface.onGlobalLayout { @@ -431,8 +431,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S val viewWidth = mView.width val instantWidth = viewWidth / 7 when { - x <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) - x >= viewWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) + x <= instantWidth -> doSkip(false) + x >= viewWidth - instantWidth -> doSkip(true) else -> togglePlayPause() } } @@ -542,13 +542,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } mPositionAtPause = 0L - val twoPercents = Math.max((mExoPlayer!!.duration / 50).toInt(), MIN_SKIP_LENGTH) - doSkip(twoPercents, forward) + doSkip(forward) } - private fun doSkip(millis: Int, forward: Boolean) { + private fun doSkip(forward: Boolean) { val curr = mExoPlayer!!.currentPosition - val newProgress = if (forward) curr + millis else curr - millis + val newProgress = if (forward) curr + FAST_FORWARD_VIDEO_MS else curr - FAST_FORWARD_VIDEO_MS val roundProgress = Math.round(newProgress / 1000f) val limitedProgress = Math.max(Math.min(mExoPlayer!!.duration.toInt() / 1000, roundProgress), 0) setPosition(limitedProgress) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 78f8b8043..5604bba2a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -118,7 +118,7 @@ const val MONTH_MILLISECONDS = MONTH_SECONDS * 1000L const val MIN_SKIP_LENGTH = 2000 const val HIDE_SYSTEM_UI_DELAY = 500L const val MAX_PRINT_SIDE_SIZE = 4096 -const val DOUBLE_TAP_SKIP_VIDEO_MS = 10000 +const val FAST_FORWARD_VIDEO_MS = 10000 const val DIRECTORY = "directory" const val MEDIUM = "medium"