1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-22 14:57:40 +01:00
smov/src/components/video/controls/PauseControl.tsx
2023-01-09 21:51:24 +01:00

28 lines
712 B
TypeScript

import { Icons } from "@/components/Icon";
import { useCallback } from "react";
import { VideoPlayerIconButton } from "../parts/VideoPlayerIconButton";
import { useVideoPlayerState } from "../VideoContext";
interface Props {
className?: string;
}
export function PauseControl(props: Props) {
const { videoState } = useVideoPlayerState();
const handleClick = useCallback(() => {
if (videoState?.isPlaying) videoState.pause();
else videoState.play();
}, [videoState]);
const icon =
videoState.isPlaying || videoState.isSeeking ? Icons.PAUSE : Icons.PLAY;
return (
<VideoPlayerIconButton
className={props.className}
icon={icon}
onClick={handleClick}
/>
);
}