"use client"; import { FC, useContext, useRef } from "react"; import { Box, Button, Stack, Text } from "../../../"; import { VideoContext } from "./"; import { secondsToHMS } from "../../../../utils"; import { useDimensions } from "../../../../hooks"; import { videoControls, videoControlsToolbar, videoControlsToolbarButtons, videoLoadedProgress, videoProgress, videoTimeline, videoTimer, } from "../Video.styles"; import { isMobile } from "react-device-detect"; const VideoControls: FC = ({ toggleMute, togglePlay, progress, duration, playerRef, }) => { const { data, handleFullscreen, init, isFullscreen, isMuted, isPlaying, setIsFullscreen, setIsMuted, setIsPlaying, } = useContext(VideoContext); const timelineRef = useRef(null); const { x, width } = useDimensions(timelineRef); if (!data?.allowControls) return null; const handleClose = () => { setIsFullscreen(false); setIsMuted(true); setIsPlaying(false); }; const handleSeek = (e: any) => { const player: any = playerRef.current; if (player) { const scrubX = e.clientX - x; const scrubPos = (scrubX / width) * duration; player.seekTo(scrubPos); } }; if (isFullscreen) { return (