diff --git a/front/src/ui/player/controls/index.tsx b/front/src/ui/player/controls/index.tsx index 5cb67d38..6d60e8e4 100644 --- a/front/src/ui/player/controls/index.tsx +++ b/front/src/ui/player/controls/index.tsx @@ -21,6 +21,7 @@ export const Controls = ({ chapters, playPrev, playNext, + seekEnd, onOpenEntriesMenu, forceShow, }: { @@ -34,6 +35,7 @@ export const Controls = ({ chapters: Chapter[]; playPrev: (() => boolean) | null; playNext: (() => boolean) | null; + seekEnd: () => void; onOpenEntriesMenu?: () => void; forceShow?: boolean; }) => { @@ -98,6 +100,7 @@ export const Controls = ({ player={player} chapters={chapters} isVisible={controlsVisible} + seekEnd={seekEnd} /> ); diff --git a/front/src/ui/player/controls/skip-chapter.tsx b/front/src/ui/player/controls/skip-chapter.tsx index 8c133ba7..95c26511 100644 --- a/front/src/ui/player/controls/skip-chapter.tsx +++ b/front/src/ui/player/controls/skip-chapter.tsx @@ -3,18 +3,24 @@ import { useTranslation } from "react-i18next"; import { useEvent, type VideoPlayer } from "react-native-video"; import type { Chapter } from "~/models"; import { Button } from "~/primitives"; -import { cn } from "~/utils"; +import { useFetch } from "~/query"; +import { Info } from "~/ui/info"; +import { cn, useQueryState } from "~/utils"; export const SkipChapterButton = ({ player, + seekEnd, chapters, isVisible, }: { player: VideoPlayer; + seekEnd: () => void; chapters: Chapter[]; isVisible: boolean; }) => { const { t } = useTranslation(); + const [slug] = useQueryState("slug", undefined!); + const { data } = useFetch(Info.infoQuery(slug)); const [progress, setProgress] = useState(player.currentTime || 0); useEvent(player, "onProgress", ({ currentTime }) => { @@ -27,12 +33,21 @@ export const SkipChapterButton = ({ if (!chapter || chapter.type === "content") return null; - if (!isVisible && progress >= chapter.startTime + 8) return null; + // delay credits appearance by a few seconds, we want to make sure it doesn't + // show on top of the end of the serie. it's common for the end credits music + // to start playing on top of the episode also. + const start = chapter.startTime + +(chapter.type === "credits") * 4; + if (!isVisible && progress >= start + 8) return null; return (