11 changed files with 147 additions and 45 deletions
@ -0,0 +1,26 @@ |
|||||||
|
import { useEffect } from "react"; |
||||||
|
import { useVideoPlayerState } from "../VideoContext"; |
||||||
|
|
||||||
|
interface ShowControlProps { |
||||||
|
series?: { |
||||||
|
episode: number; |
||||||
|
season: number; |
||||||
|
}; |
||||||
|
title?: string; |
||||||
|
} |
||||||
|
|
||||||
|
export function ShowControl(props: ShowControlProps) { |
||||||
|
const { videoState } = useVideoPlayerState(); |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
videoState.setShowData({ |
||||||
|
current: props.series, |
||||||
|
isSeries: !!props.series, |
||||||
|
title: props.title, |
||||||
|
}); |
||||||
|
// we only want it to run when props change, not when videoState changes
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [props]); |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
import { useVideoPlayerState } from "../VideoContext"; |
||||||
|
|
||||||
|
export function ShowTitleControl() { |
||||||
|
const { videoState } = useVideoPlayerState(); |
||||||
|
|
||||||
|
if (!videoState.seasonData.isSeries) return null; |
||||||
|
if (!videoState.seasonData.title || !videoState.seasonData.current) |
||||||
|
return null; |
||||||
|
|
||||||
|
const cur = videoState.seasonData.current; |
||||||
|
const selectedText = `S${cur.season} E${cur.episode}`; |
||||||
|
|
||||||
|
return ( |
||||||
|
<p className="ml-8 select-none space-x-2 font-bold text-white"> |
||||||
|
<span>{selectedText}</span> |
||||||
|
<span className="opacity-50">{videoState.seasonData.title}</span> |
||||||
|
</p> |
||||||
|
); |
||||||
|
} |
Loading…
Reference in new issue