diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 8de78a041..4bc39503d 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -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() } diff --git a/app/src/main/res/layout/dialog_playback_speed.xml b/app/src/main/res/layout/dialog_playback_speed.xml new file mode 100644 index 000000000..7e190af0f --- /dev/null +++ b/app/src/main/res/layout/dialog_playback_speed.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file