Browse Source

Refactor video playback speed options

pull/612/head
qtchaos 2 years ago
parent
commit
c3494c2f84
No known key found for this signature in database
GPG Key ID: 7DA98B2B9EF06A90
  1. 8
      src/components/player/internals/KeyboardEvents.tsx

8
src/components/player/internals/KeyboardEvents.tsx

@ -93,12 +93,10 @@ export function KeyboardEvents() { @@ -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);
}

Loading…
Cancel
Save