Browse Source

Add check for non existent index.

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

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

@ -94,7 +94,8 @@ export function KeyboardEvents() {
// Video playback speed // Video playback speed
if (k === ">" || k === "<") { if (k === ">" || k === "<") {
const options = [0.25, 0.5, 1, 1.5, 2]; const options = [0.25, 0.5, 1, 1.5, 2];
const idx = options.indexOf(dataRef.current.mediaPlaying?.playbackRate); let idx = options.indexOf(dataRef.current.mediaPlaying?.playbackRate);
if (idx === -1) idx = options.indexOf(1);
const nextIdx = idx + (k === ">" ? 1 : -1); const nextIdx = idx + (k === ">" ? 1 : -1);
const next = options[nextIdx]; const next = options[nextIdx];
if (next) dataRef.current.display?.setPlaybackRate(next); if (next) dataRef.current.display?.setPlaybackRate(next);

Loading…
Cancel
Save