mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40: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.CronetHelper
|
||||||
import com.github.libretube.api.RetrofitInstance
|
import com.github.libretube.api.RetrofitInstance
|
||||||
import com.github.libretube.api.SubscriptionHelper
|
import com.github.libretube.api.SubscriptionHelper
|
||||||
|
import com.github.libretube.databinding.DialogPlaybackSpeedBinding
|
||||||
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
||||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||||
import com.github.libretube.databinding.FragmentPlayerBinding
|
import com.github.libretube.databinding.FragmentPlayerBinding
|
||||||
@ -509,17 +510,17 @@ class PlayerFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlaybackSpeedClicked() {
|
override fun onPlaybackSpeedClicked() {
|
||||||
val playbackSpeeds = context?.resources?.getStringArray(R.array.playbackSpeed)!!
|
val playbackSpeedBinding = DialogPlaybackSpeedBinding.inflate(layoutInflater)
|
||||||
val playbackSpeedValues =
|
playbackSpeedBinding.slider.value = exoPlayer.playbackParameters.speed
|
||||||
context?.resources?.getStringArray(R.array.playbackSpeedValues)!!
|
|
||||||
|
|
||||||
// change playback speed dialog
|
// change playback speed dialog
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setTitle(R.string.change_playback_speed)
|
.setTitle(R.string.change_playback_speed)
|
||||||
.setItems(playbackSpeeds) { _, index ->
|
.setView(playbackSpeedBinding.root)
|
||||||
// set the new playback speed
|
.setNegativeButton(R.string.cancel, null)
|
||||||
val newPlaybackSpeed = playbackSpeedValues[index].toFloat()
|
.setPositiveButton(R.string.okay) { _, _ ->
|
||||||
exoPlayer.setPlaybackSpeed(newPlaybackSpeed)
|
exoPlayer.setPlaybackSpeed(
|
||||||
|
playbackSpeedBinding.slider.value
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.show()
|
.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