mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-25 14:19:27 +03:00
seeking preview on keyframes
This commit is contained in:
parent
9a6a877468
commit
e0a25cf38c
3 changed files with 14 additions and 4 deletions
|
@ -51,6 +51,8 @@ class Gestures(
|
|||
return true
|
||||
}
|
||||
|
||||
private var scrollDiff: Float? = null
|
||||
|
||||
override fun onScroll(
|
||||
e1: MotionEvent,
|
||||
e2: MotionEvent,
|
||||
|
@ -82,7 +84,9 @@ class Gestures(
|
|||
activity.verticalScrollRight(1.5F * distanceY / height)
|
||||
}
|
||||
STATE_HORIZONTAL -> {
|
||||
activity.horizontalScroll(150F * -dx / width)
|
||||
val diff = 150F * -dx / width
|
||||
scrollDiff = diff
|
||||
activity.horizontalScroll(diff)
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
@ -91,6 +95,10 @@ class Gestures(
|
|||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||
if (event.action == MotionEvent.ACTION_UP) {
|
||||
if (scrollState == STATE_HORIZONTAL) {
|
||||
scrollDiff?.let { activity.horizontalScroll(it, final = true) }
|
||||
scrollDiff = null
|
||||
}
|
||||
if (scrollState != STATE_UP) {
|
||||
scrollState = STATE_UP
|
||||
}
|
||||
|
|
|
@ -810,7 +810,7 @@ class PlayerActivity :
|
|||
fun initSeek() {
|
||||
initialSeek = player.timePos ?: -1
|
||||
}
|
||||
fun horizontalScroll(diff: Float) {
|
||||
fun horizontalScroll(diff: Float, final: Boolean = false) {
|
||||
// disable seeking when timePos is not available
|
||||
val duration = player.duration ?: 0
|
||||
if (duration == 0 || initialSeek < 0) {
|
||||
|
@ -820,7 +820,7 @@ class PlayerActivity :
|
|||
val newDiff = newPos - initialSeek
|
||||
|
||||
playerControls.hideUiForSeek()
|
||||
if (preferences.getPlayerSmoothSeek()) player.timePos = newPos else MPVLib.command(arrayOf("seek", newPos.toString(), "absolute+keyframes"))
|
||||
if (preferences.getPlayerSmoothSeek() && final) player.timePos = newPos else MPVLib.command(arrayOf("seek", newPos.toString(), "absolute+keyframes"))
|
||||
playerControls.updatePlaybackPos(newPos)
|
||||
|
||||
val diffText = Utils.prettyTime(newDiff, true)
|
||||
|
|
|
@ -40,7 +40,7 @@ class PlayerControlsView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
return
|
||||
}
|
||||
hideUiForSeek()
|
||||
activity.player.timePos = progress
|
||||
MPVLib.command(arrayOf("seek", progress.toString(), "absolute+keyframes"))
|
||||
updatePlaybackPos(progress)
|
||||
|
||||
val duration = activity.player.duration ?: 0
|
||||
|
@ -60,6 +60,8 @@ class PlayerControlsView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
val newPos = seekBar.progress
|
||||
if (preferences.getPlayerSmoothSeek()) activity.player.timePos = newPos else MPVLib.command(arrayOf("seek", newPos.toString(), "absolute+keyframes"))
|
||||
userIsOperatingSeekbar = false
|
||||
animationHandler.removeCallbacks(hideUiForSeekRunnable)
|
||||
animationHandler.postDelayed(hideUiForSeekRunnable, 500L)
|
||||
|
|
Loading…
Reference in a new issue