From c3494c2f845682435e5b7f32679c0e4090017206 Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Thu, 28 Dec 2023 21:57:14 +0200 Subject: [PATCH] Refactor video playback speed options --- src/components/player/internals/KeyboardEvents.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/player/internals/KeyboardEvents.tsx b/src/components/player/internals/KeyboardEvents.tsx index 5900a990..29432a4f 100644 --- a/src/components/player/internals/KeyboardEvents.tsx +++ b/src/components/player/internals/KeyboardEvents.tsx @@ -93,12 +93,10 @@ export function KeyboardEvents() { // Video playback speed if (k === ">" || k === "<") { - const playbackRates = [0.25, 0.5, 1, 1.5, 2]; - const idx = playbackRates.indexOf( - dataRef.current.mediaPlaying?.playbackRate, - ); + const options = [0.25, 0.5, 1, 1.5, 2]; + const idx = options.indexOf(dataRef.current.mediaPlaying?.playbackRate); const nextIdx = idx + (k === ">" ? 1 : -1); - const next = playbackRates[nextIdx]; + const next = options[nextIdx]; if (next) dataRef.current.display?.setPlaybackRate(next); }