You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
import { useCallback } from "react"; |
|
|
|
import { useVideoPlayerDescriptor } from "@/_oldvideo/state/hooks"; |
|
import { useControls } from "@/_oldvideo/state/logic/controls"; |
|
import { useInterface } from "@/_oldvideo/state/logic/interface"; |
|
import { Icons } from "@/components/Icon"; |
|
import { canFullscreen } from "@/utils/detectFeatures"; |
|
|
|
import { VideoPlayerIconButton } from "../parts/VideoPlayerIconButton"; |
|
|
|
interface Props { |
|
className?: string; |
|
} |
|
|
|
export function FullscreenAction(props: Props) { |
|
const descriptor = useVideoPlayerDescriptor(); |
|
const videoInterface = useInterface(descriptor); |
|
const controls = useControls(descriptor); |
|
|
|
const handleClick = useCallback(() => { |
|
if (videoInterface.isFullscreen) controls.exitFullscreen(); |
|
else controls.enterFullscreen(); |
|
}, [controls, videoInterface]); |
|
|
|
if (!canFullscreen()) return null; |
|
|
|
return ( |
|
<VideoPlayerIconButton |
|
className={props.className} |
|
onClick={handleClick} |
|
icon={videoInterface.isFullscreen ? Icons.COMPRESS : Icons.EXPAND} |
|
/> |
|
); |
|
}
|
|
|