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

25 lines
592 B
TypeScript
Raw Normal View History

2023-01-08 15:37:16 +01:00
import { useCallback } from "react";
import { useVideoPlayerState } from "../VideoContext";
2023-01-08 13:15:32 +01:00
export function PauseControl() {
2023-01-08 15:37:16 +01:00
const { videoState } = useVideoPlayerState();
2023-01-08 13:15:32 +01:00
const handleClick = useCallback(() => {
2023-01-08 15:37:16 +01:00
if (videoState?.isPlaying) videoState.pause();
else videoState.play();
}, [videoState]);
2023-01-08 13:15:32 +01:00
2023-01-08 17:51:38 +01:00
const text =
2023-01-08 16:23:42 +01:00
videoState.isPlaying || videoState.isSeeking ? "playing" : "paused";
2023-01-08 13:15:32 +01:00
return (
2023-01-08 16:23:42 +01:00
<button
className="m-1 rounded bg-denim-100 p-1 text-white hover:opacity-75"
type="button"
onClick={handleClick}
>
2023-01-08 13:15:32 +01:00
{text}
</button>
);
}