allow increasing or decreasing playback speed by pressing the side icons

This commit is contained in:
tibbi 2021-03-06 23:21:48 +01:00
parent 6f7637b32c
commit c9772c6a54

View file

@ -97,11 +97,27 @@ class PlaybackSpeedFragment : BottomSheetDialogFragment() {
}
private fun reduceSpeed() {
var currentProgress = seekBar?.progress ?: return
val currentSpeed = context!!.config.playbackSpeed
while (currentProgress > 0) {
val newSpeed = getPlaybackSpeed(--currentProgress)
if (newSpeed != currentSpeed) {
seekBar!!.progress = currentProgress
break
}
}
}
private fun increaseSpeed() {
var currentProgress = seekBar?.progress ?: return
val currentSpeed = context!!.config.playbackSpeed
while (currentProgress < MAX_PROGRESS) {
val newSpeed = getPlaybackSpeed(++currentProgress)
if (newSpeed != currentSpeed) {
seekBar!!.progress = currentProgress
break
}
}
}
private fun formatPlaybackSpeed(value: Float) = String.format("%.2f", value)