mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50:30 +05:30
add continous playback speed slider
This commit is contained in:
parent
1e5bd4d6fc
commit
207fe64b58
@ -43,6 +43,7 @@ import com.github.libretube.adapters.TrendingAdapter
|
||||
import com.github.libretube.api.CronetHelper
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.api.SubscriptionHelper
|
||||
import com.github.libretube.databinding.DialogPlaybackSpeedBinding
|
||||
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||
import com.github.libretube.databinding.FragmentPlayerBinding
|
||||
@ -509,17 +510,17 @@ class PlayerFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
override fun onPlaybackSpeedClicked() {
|
||||
val playbackSpeeds = context?.resources?.getStringArray(R.array.playbackSpeed)!!
|
||||
val playbackSpeedValues =
|
||||
context?.resources?.getStringArray(R.array.playbackSpeedValues)!!
|
||||
|
||||
val playbackSpeedBinding = DialogPlaybackSpeedBinding.inflate(layoutInflater)
|
||||
playbackSpeedBinding.slider.value = exoPlayer.playbackParameters.speed
|
||||
// change playback speed dialog
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.change_playback_speed)
|
||||
.setItems(playbackSpeeds) { _, index ->
|
||||
// set the new playback speed
|
||||
val newPlaybackSpeed = playbackSpeedValues[index].toFloat()
|
||||
exoPlayer.setPlaybackSpeed(newPlaybackSpeed)
|
||||
.setView(playbackSpeedBinding.root)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.okay) { _, _ ->
|
||||
exoPlayer.setPlaybackSpeed(
|
||||
playbackSpeedBinding.slider.value
|
||||
)
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
16
app/src/main/res/layout/dialog_playback_speed.xml
Normal file
16
app/src/main/res/layout/dialog_playback_speed.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:value="1"
|
||||
android:valueFrom="0.25"
|
||||
android:valueTo="5" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user