2023-01-08 16:23:42 +01:00
|
|
|
import { useCallback } from "react";
|
|
|
|
import { useVideoPlayerState } from "../VideoContext";
|
2023-01-08 13:15:32 +01:00
|
|
|
|
|
|
|
export function FullscreenControl() {
|
2023-01-08 16:23:42 +01:00
|
|
|
const { videoState } = useVideoPlayerState();
|
2023-01-08 13:15:32 +01:00
|
|
|
|
2023-01-08 16:23:42 +01:00
|
|
|
const handleClick = useCallback(() => {
|
|
|
|
if (videoState.isFullscreen) videoState.exitFullscreen();
|
|
|
|
else videoState.enterFullscreen();
|
|
|
|
}, [videoState]);
|
2023-01-08 13:15:32 +01:00
|
|
|
|
2023-01-08 16:23:42 +01:00
|
|
|
let text = "not fullscreen";
|
|
|
|
if (videoState.isFullscreen) text = "in fullscreen";
|
2023-01-08 13:15:32 +01:00
|
|
|
|
2023-01-08 16:23:42 +01:00
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className="m-1 rounded bg-denim-100 p-1 text-white hover:opacity-75"
|
|
|
|
type="button"
|
|
|
|
onClick={handleClick}
|
|
|
|
>
|
|
|
|
{text}
|
|
|
|
</button>
|
|
|
|
);
|
2023-01-08 13:15:32 +01:00
|
|
|
}
|