diff --git a/src/components/player/internals/KeyboardEvents.tsx b/src/components/player/internals/KeyboardEvents.tsx index 4e8e3f81..3a833e76 100644 --- a/src/components/player/internals/KeyboardEvents.tsx +++ b/src/components/player/internals/KeyboardEvents.tsx @@ -9,6 +9,8 @@ import { useEmpheralVolumeStore } from "@/stores/volume"; export function KeyboardEvents() { const router = useOverlayRouter(""); const display = usePlayerStore((s) => s.display); + const mediaProgress = usePlayerStore((s) => s.progress); + const { isSeeking } = usePlayerStore((s) => s.interface); const mediaPlaying = usePlayerStore((s) => s.mediaPlaying); const time = usePlayerStore((s) => s.progress.time); const { setVolume, toggleMute } = useVolume(); @@ -27,6 +29,8 @@ export function KeyboardEvents() { toggleLastUsed, display, mediaPlaying, + mediaProgress, + isSeeking, isRolling, time, router, @@ -40,6 +44,8 @@ export function KeyboardEvents() { toggleLastUsed, display, mediaPlaying, + mediaProgress, + isSeeking, isRolling, time, router, @@ -52,6 +58,8 @@ export function KeyboardEvents() { toggleLastUsed, display, mediaPlaying, + mediaProgress, + isSeeking, isRolling, time, router, @@ -83,11 +91,29 @@ export function KeyboardEvents() { ); if (k === "m") dataRef.current.toggleMute(); + // Video playback speed + if (k === ">" || k === "<") { + const options = [0.25, 0.5, 1, 1.5, 2]; + 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); + } + // Video progress if (k === "ArrowRight") dataRef.current.display?.setTime(dataRef.current.time + 5); if (k === "ArrowLeft") dataRef.current.display?.setTime(dataRef.current.time - 5); + if (k === "j") + dataRef.current.display?.setTime(dataRef.current.time - 10); + if (k === "l") + dataRef.current.display?.setTime(dataRef.current.time + 10); + if (k === "." && dataRef.current.mediaPlaying?.isPaused) + dataRef.current.display?.setTime(dataRef.current.time + 1); + if (k === "," && dataRef.current.mediaPlaying?.isPaused) + dataRef.current.display?.setTime(dataRef.current.time - 1); // Utils if (k === "f") dataRef.current.display?.toggleFullscreen();