mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-22 14:57:40 +01:00
29 lines
784 B
TypeScript
29 lines
784 B
TypeScript
import { Icons } from "@/components/Icon";
|
|
import { useCallback } from "react";
|
|
import { VideoPlayerIconButton } from "../parts/VideoPlayerIconButton";
|
|
import { useVideoPlayerState } from "../VideoContext";
|
|
|
|
const canFullscreen = document.fullscreenEnabled;
|
|
|
|
interface Props {
|
|
className?: string;
|
|
}
|
|
|
|
export function FullscreenControl(props: Props) {
|
|
const { videoState } = useVideoPlayerState();
|
|
|
|
const handleClick = useCallback(() => {
|
|
if (videoState.isFullscreen) videoState.exitFullscreen();
|
|
else videoState.enterFullscreen();
|
|
}, [videoState]);
|
|
|
|
if (!canFullscreen) return null;
|
|
|
|
return (
|
|
<VideoPlayerIconButton
|
|
className={props.className}
|
|
onClick={handleClick}
|
|
icon={videoState.isFullscreen ? Icons.COMPRESS : Icons.EXPAND}
|
|
/>
|
|
);
|
|
}
|