fix #697, add a minimum video skip length of 2 seconds, for short videos

This commit is contained in:
tibbi 2018-03-14 00:05:00 +01:00
parent bc36bc1ade
commit e9638d5152
1 changed files with 5 additions and 2 deletions

View File

@ -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()
}