add hotkeys

This commit is contained in:
an-lee
2024-01-10 14:13:49 +08:00
parent 5168201b8e
commit 1bfa3d79cd
5 changed files with 38 additions and 1 deletions

View File

@@ -26,6 +26,8 @@ import {
DefaultVideoLayout,
defaultLayoutIcons,
} from "@vidstack/react/player/layouts/default";
import { useHotkeys } from "react-hotkeys-hook";
import { Key } from "ts-key-enum";
const minPxPerSecBase = 150;
@@ -499,6 +501,15 @@ export const MediaPlayer = (props: {
return fitZoomRatio;
};
useHotkeys(
" ",
() => {
if (!wavesurfer) return;
onPlayClick();
},
[wavesurfer]
);
return (
<>
<div className="mb-2" ref={containerRef} />

View File

@@ -5,6 +5,7 @@ import RecordPlugin from "wavesurfer.js/dist/plugins/record";
import WaveSurfer from "wavesurfer.js";
import { cn } from "@renderer/lib/utils";
import { RadialProgress, useToast } from "@renderer/components/ui";
import { useHotkeys } from "react-hotkeys-hook";
export const RecordButton = (props: {
className?: string;
@@ -17,6 +18,11 @@ export const RecordButton = (props: {
const [duration, setDuration] = useState<number>(0);
const { toast } = useToast();
useHotkeys(["command+alt+r", "control+alt+r"], () => {
if (disabled) return;
setIsRecording((isRecording) => !isRecording);
});
useEffect(() => {
if (!isRecording) return;

View File

@@ -13,7 +13,6 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@renderer/components/ui";
import { ChevronDownIcon, Trash2Icon, InfoIcon, Share2Icon } from "lucide-react";