import { useMemo } from "react"; import { useVideoPlayerState } from "../VideoContext"; export function ShowTitleControl() { const { videoState } = useVideoPlayerState(); const { current, seasons } = videoState.seasonData; const currentSeasonInfo = useMemo(() => { return seasons?.find((season) => season.id === current?.seasonId); }, [seasons, current]); const currentEpisodeInfo = useMemo(() => { return currentSeasonInfo?.episodes?.find( (episode) => episode.id === current?.episodeId ); }, [currentSeasonInfo, current]); if (!videoState.seasonData.isSeries) return null; if (!videoState.seasonData.current) return null; const selectedText = `S${currentSeasonInfo?.number} E${currentEpisodeInfo?.number}`; return (
{selectedText} {currentEpisodeInfo?.title}
); }