From 5e52ea8e8fdcea482be57b75ee94c46c00c5e33d Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Thu, 28 Dec 2023 22:53:47 +0200 Subject: [PATCH] Add check for non existent index. --- src/components/player/internals/KeyboardEvents.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/player/internals/KeyboardEvents.tsx b/src/components/player/internals/KeyboardEvents.tsx index 6373b0b5..3a833e76 100644 --- a/src/components/player/internals/KeyboardEvents.tsx +++ b/src/components/player/internals/KeyboardEvents.tsx @@ -94,7 +94,8 @@ export function KeyboardEvents() { // Video playback speed if (k === ">" || k === "<") { 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 next = options[nextIdx]; if (next) dataRef.current.display?.setPlaybackRate(next);