mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Fix the playback speed value
This commit is contained in:
parent
67982186c6
commit
c5fb672d44
@ -0,0 +1,9 @@
|
|||||||
|
package com.github.libretube.extensions
|
||||||
|
|
||||||
|
import kotlin.math.pow
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
fun Float.round(decimalPlaces: Int): Float {
|
||||||
|
return (this * 10.0.pow(decimalPlaces.toDouble())).roundToInt() / 10.0.pow(decimalPlaces.toDouble())
|
||||||
|
.toFloat()
|
||||||
|
}
|
@ -6,6 +6,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import com.github.libretube.databinding.PlaybackBottomSheetBinding
|
import com.github.libretube.databinding.PlaybackBottomSheetBinding
|
||||||
|
import com.github.libretube.extensions.round
|
||||||
import com.google.android.exoplayer2.PlaybackParameters
|
import com.google.android.exoplayer2.PlaybackParameters
|
||||||
import com.google.android.exoplayer2.Player
|
import com.google.android.exoplayer2.Player
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
@ -31,11 +32,11 @@ class PlaybackSpeedSheet(
|
|||||||
binding.pitch.value = player.playbackParameters.pitch
|
binding.pitch.value = player.playbackParameters.pitch
|
||||||
|
|
||||||
binding.speed.addOnChangeListener { _, value, _ ->
|
binding.speed.addOnChangeListener { _, value, _ ->
|
||||||
onChange(value, binding.pitch.value)
|
onChange(value, binding.pitch.value.round(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.pitch.addOnChangeListener { _, value, _ ->
|
binding.pitch.addOnChangeListener { _, value, _ ->
|
||||||
onChange(binding.speed.value, value)
|
onChange(binding.speed.value.round(2), value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user