Add check for non existent index.

This commit is contained in:
qtchaos 2023-12-28 22:53:47 +02:00
parent 27b28a6d96
commit 5e52ea8e8f
No known key found for this signature in database
GPG key ID: 7DA98B2B9EF06A90

View file

@ -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);