From e9638d5152b0c996557951110fdec7f9925cc46b Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 14 Mar 2018 00:05:00 +0100 Subject: [PATCH] fix #697, add a minimum video skip length of 2 seconds, for short videos --- .../simplemobiletools/gallery/fragments/VideoFragment.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index af1cfc27d..eb26d311f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -28,6 +28,7 @@ import java.io.IOException class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSeekBarChangeListener { private val PROGRESS = "progress" + private val MIN_SKIP_LENGTH = 2000 private var mMediaPlayer: MediaPlayer? = null private var mSurfaceView: SurfaceView? = null @@ -481,9 +482,11 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee } val curr = mMediaPlayer!!.currentPosition - val twoPercents = mMediaPlayer!!.duration / 50 + val twoPercents = Math.max(mMediaPlayer!!.duration / 50, MIN_SKIP_LENGTH) val newProgress = if (forward) curr + twoPercents else curr - twoPercents - setProgress(Math.round(newProgress / 1000f)) + val roundProgress = Math.round(newProgress / 1000f) + val limitedProgress = Math.max(Math.min(mMediaPlayer!!.duration / 1000, roundProgress), 0) + setProgress(limitedProgress) if (!mIsPlaying) { togglePlayPause() }