origin/apps/web/src/components/presentation/video-player/VideoPlayerLayout.tsx

35 lines
864 B
TypeScript
Raw Normal View History

2025-01-08 00:56:15 +08:00
import { useContext } from "react";
import { VideoPlayerContext } from "./VideoPlayer";
import Controls from "./VideoControls";
import { AnimatePresence } from "framer-motion";
2025-01-08 20:29:07 +08:00
import { VideoDisplay } from "./VideoDisplay";
2025-01-08 00:56:15 +08:00
import LoadingOverlay from "./LoadingOverlay";
export default function VideoPlayerLayout() {
const {
isReady,
setIsHovering,
setShowControls,
showControls,
isDragging,
} = useContext(VideoPlayerContext);
return (
<>
<div
2025-01-08 20:29:07 +08:00
className={`relative w-full bg-black rounded-lg overflow-hidden`}
2025-02-26 22:54:22 +08:00
style={{ aspectRatio: "16/9" }}
2025-01-08 00:56:15 +08:00
onMouseEnter={() => {
setIsHovering(true);
setShowControls(true);
}}>
{!isReady && <LoadingOverlay></LoadingOverlay>}
2025-01-08 20:29:07 +08:00
<VideoDisplay></VideoDisplay>
2025-01-08 00:56:15 +08:00
<AnimatePresence>
{(showControls || isDragging) && <Controls />}
</AnimatePresence>
</div>
</>
);
}