fix #1223, updating video player gestures a bit
add double tap to skip forward/backward, double tap center to toggle play/pause
This commit is contained in:
parent
60b3023564
commit
f175c71621
2 changed files with 22 additions and 3 deletions
|
@ -81,7 +81,7 @@ dependencies {
|
||||||
implementation 'org.apache.sanselan:sanselan:0.97-incubator'
|
implementation 'org.apache.sanselan:sanselan:0.97-incubator'
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
implementation 'com.caverock:androidsvg-aar:1.3'
|
implementation 'com.caverock:androidsvg-aar:1.3'
|
||||||
implementation 'com.github.tibbi:gestureviews:8dccb8450b'
|
implementation 'com.github.tibbi:gestureviews:512f929d82'
|
||||||
implementation 'com.github.tibbi:subsampling-scale-image-view:d404e74e39'
|
implementation 'com.github.tibbi:subsampling-scale-image-view:d404e74e39'
|
||||||
|
|
||||||
kapt 'com.github.bumptech.glide:compiler:4.10.0'
|
kapt 'com.github.bumptech.glide:compiler:4.10.0'
|
||||||
|
|
|
@ -39,6 +39,7 @@ import java.io.FileInputStream
|
||||||
|
|
||||||
class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener {
|
class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener {
|
||||||
private val PROGRESS = "progress"
|
private val PROGRESS = "progress"
|
||||||
|
private val DOUBLE_TAP_SKIP_MS = 10000
|
||||||
|
|
||||||
private var mIsFullscreen = false
|
private var mIsFullscreen = false
|
||||||
private var mWasFragmentInit = false
|
private var mWasFragmentInit = false
|
||||||
|
@ -86,6 +87,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
video_duration.setOnClickListener { skip(true) }
|
video_duration.setOnClickListener { skip(true) }
|
||||||
video_holder.setOnClickListener { toggleFullscreen() }
|
video_holder.setOnClickListener { toggleFullscreen() }
|
||||||
video_preview.setOnClickListener { toggleFullscreen() }
|
video_preview.setOnClickListener { toggleFullscreen() }
|
||||||
|
video_surface_frame.controller.settings.swallowDoubleTaps = true
|
||||||
|
|
||||||
video_play_outline.setOnClickListener {
|
video_play_outline.setOnClickListener {
|
||||||
if (mConfig.openVideosOnSeparateScreen) {
|
if (mConfig.openVideosOnSeparateScreen) {
|
||||||
|
@ -129,6 +131,19 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDoubleTap(e: MotionEvent?): Boolean {
|
||||||
|
val viewWidth = width
|
||||||
|
val instantWidth = viewWidth / 7
|
||||||
|
val clickedX = e?.rawX ?: 0f
|
||||||
|
when {
|
||||||
|
clickedX <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_MS, false)
|
||||||
|
clickedX >= viewWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_MS, true)
|
||||||
|
else -> togglePlayPause()
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (mConfig.allowDownGesture) {
|
if (mConfig.allowDownGesture) {
|
||||||
|
@ -521,9 +536,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
}
|
}
|
||||||
|
|
||||||
mPositionAtPause = 0L
|
mPositionAtPause = 0L
|
||||||
val curr = mExoPlayer!!.currentPosition
|
|
||||||
val twoPercents = Math.max((mExoPlayer!!.duration / 50).toInt(), MIN_SKIP_LENGTH)
|
val twoPercents = Math.max((mExoPlayer!!.duration / 50).toInt(), MIN_SKIP_LENGTH)
|
||||||
val newProgress = if (forward) curr + twoPercents else curr - twoPercents
|
doSkip(twoPercents, forward)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doSkip(millis: Int, forward: Boolean) {
|
||||||
|
val curr = mExoPlayer!!.currentPosition
|
||||||
|
val newProgress = if (forward) curr + millis else curr - millis
|
||||||
val roundProgress = Math.round(newProgress / 1000f)
|
val roundProgress = Math.round(newProgress / 1000f)
|
||||||
val limitedProgress = Math.max(Math.min(mExoPlayer!!.duration.toInt(), roundProgress), 0)
|
val limitedProgress = Math.max(Math.min(mExoPlayer!!.duration.toInt(), roundProgress), 0)
|
||||||
setPosition(limitedProgress)
|
setPosition(limitedProgress)
|
||||||
|
|
Loading…
Reference in a new issue