diff --git a/k-tv-frontend/app/(main)/tv/page.tsx b/k-tv-frontend/app/(main)/tv/page.tsx index 3086b35..dd7f097 100644 --- a/k-tv-frontend/app/(main)/tv/page.tsx +++ b/k-tv-frontend/app/(main)/tv/page.tsx @@ -14,9 +14,10 @@ import { } from "./components"; import type { SubtitleTrack } from "./components/video-player"; import type { LogoPosition } from "@/lib/types"; -import { Maximize2, Minimize2, Volume1, Volume2, VolumeX } from "lucide-react"; +import { Cast, Maximize2, Minimize2, Volume1, Volume2, VolumeX } from "lucide-react"; import { useAuthContext } from "@/context/auth-context"; import { useChannels, useCurrentBroadcast, useEpg } from "@/hooks/use-channels"; +import { useCast } from "@/hooks/use-cast"; import { useStreamUrl, fmtTime, @@ -166,6 +167,20 @@ function TvPageContent() { const toggleMute = useCallback(() => setIsMuted((m) => !m), []); const VolumeIcon = isMuted || volume === 0 ? VolumeX : volume < 0.5 ? Volume1 : Volume2; + const { castAvailable, isCasting, castDeviceName, requestCast, stopCasting } = useCast(); + + // Auto-mute local video while casting, restore on cast end + const prevMutedRef = useRef(false); + useEffect(() => { + if (isCasting) { + prevMutedRef.current = isMuted; + setIsMuted(true); + } else { + setIsMuted(prevMutedRef.current); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isCasting]); + // Channel jump by number (e.g. press "1","4" → jump to ch 14 after 1.5 s) const [channelInput, setChannelInput] = useState(""); const channelInputTimer = useRef | null>(null); @@ -654,6 +669,18 @@ function TvPageContent() { : } + {castAvailable && ( + + )} +