diff --git a/src/components/player/atoms/Captions.tsx b/src/components/player/atoms/Captions.tsx new file mode 100644 index 00000000..89e419e0 --- /dev/null +++ b/src/components/player/atoms/Captions.tsx @@ -0,0 +1,28 @@ +import { useEffect } from "react"; + +import { Icons } from "@/components/Icon"; +import { OverlayAnchor } from "@/components/overlays/OverlayAnchor"; +import { VideoPlayerButton } from "@/components/player/internals/Button"; +import { useOverlayRouter } from "@/hooks/useOverlayRouter"; +import { usePlayerStore } from "@/stores/player/store"; + +export function Captions() { + const router = useOverlayRouter("settings"); + const setHasOpenOverlay = usePlayerStore((s) => s.setHasOpenOverlay); + + useEffect(() => { + setHasOpenOverlay(router.isRouterActive); + }, [setHasOpenOverlay, router.isRouterActive]); + + return ( + + { + router.open(); + router.navigate("/captionsOverlay"); + }} + icon={Icons.CAPTIONS} + /> + + ); +} diff --git a/src/components/player/atoms/Settings.tsx b/src/components/player/atoms/Settings.tsx index b3eb2a59..a4059f1e 100644 --- a/src/components/player/atoms/Settings.tsx +++ b/src/components/player/atoms/Settings.tsx @@ -54,6 +54,12 @@ function SettingsOverlay({ id }: { id: string }) { + + + + + {/* This is used by the captions shortcut in bottomControls of player */} + @@ -68,6 +74,17 @@ function SettingsOverlay({ id }: { id: string }) { + {/* This is used by the captions shortcut in bottomControls of player */} + + + + + diff --git a/src/components/player/atoms/index.ts b/src/components/player/atoms/index.ts index 3caf8154..6be88fd6 100644 --- a/src/components/player/atoms/index.ts +++ b/src/components/player/atoms/index.ts @@ -16,3 +16,4 @@ export * from "./VolumeChangedPopout"; export * from "./NextEpisodeButton"; export * from "./Chromecast"; export * from "./CastingNotification"; +export * from "./Captions"; diff --git a/src/components/player/atoms/settings/CaptionsView.tsx b/src/components/player/atoms/settings/CaptionsView.tsx index 709ad067..fd8b3ce8 100644 --- a/src/components/player/atoms/settings/CaptionsView.tsx +++ b/src/components/player/atoms/settings/CaptionsView.tsx @@ -120,7 +120,13 @@ function useSubtitleList(subs: CaptionListItem[], searchQuery: string) { }, [subs, searchQuery, unknownChoice]); } -export function CaptionsView({ id }: { id: string }) { +export function CaptionsView({ + id, + backLink, +}: { + id: string; + backLink?: true; +}) { const { t } = useTranslation(); const router = useOverlayRouter(id); const selectedCaptionId = usePlayerStore((s) => s.caption.selected?.id); @@ -213,20 +219,36 @@ export function CaptionsView({ id }: { id: string }) { - router.navigate("/")} - rightSide={ - router.navigate("/captions/settings")} - className="-mr-2 -my-1 px-2 p-[0.4em] rounded tabbable hover:bg-video-context-light hover:bg-opacity-10" - > - {t("player.menus.subtitles.customizeLabel")} - - } - > - {t("player.menus.subtitles.title")} - + {backLink ? ( + router.navigate("/")} + rightSide={ + router.navigate("/captions/settings")} + className="-mr-2 -my-1 px-2 p-[0.4em] rounded tabbable hover:bg-video-context-light hover:bg-opacity-10" + > + {t("player.menus.subtitles.customizeLabel")} + + } + > + {t("player.menus.subtitles.title")} + + ) : ( + router.navigate("/captions/settings")} + className="-mr-2 -my-1 px-2 p-[0.4em] rounded tabbable hover:bg-video-context-light hover:bg-opacity-10" + > + {t("player.menus.subtitles.customizeLabel")} + + } + > + {t("player.menus.subtitles.title")} + + )} router.navigate("/captions/opensubtitles")} + onClick={() => + router.navigate( + backLink + ? "/captions/opensubtitles" + : "/captions/opensubtitlesOverlay", + ) + } className="p-[0.5em] rounded tabbable hover:bg-video-context-hoverColor hover:bg-opacity-50" > @@ -259,7 +287,13 @@ export function CaptionsView({ id }: { id: string }) { {t("player.menus.subtitles.empty")} router.navigate("/captions/opensubtitles")} + onClick={() => + router.navigate( + backLink + ? "/captions/opensubtitles" + : "/captions/opensubtitlesOverlay", + ) + } className="p-1 w-3/4 rounded tabbable duration-200 bg-opacity-10 bg-video-context-light hover:bg-opacity-20" > {t("player.menus.subtitles.scrapeButton")} diff --git a/src/components/player/atoms/settings/Opensubtitles.tsx b/src/components/player/atoms/settings/Opensubtitles.tsx index b4dd2b1b..3ead05cd 100644 --- a/src/components/player/atoms/settings/Opensubtitles.tsx +++ b/src/components/player/atoms/settings/Opensubtitles.tsx @@ -73,7 +73,13 @@ function useSubtitleList(subs: CaptionListItem[], searchQuery: string) { }, [subs, searchQuery, unknownChoice]); } -export function OpenSubtitlesCaptionView({ id }: { id: string }) { +export function OpenSubtitlesCaptionView({ + id, + overlayBackLink, +}: { + id: string; + overlayBackLink?: boolean; +}) { const { t } = useTranslation(); const router = useOverlayRouter(id); const selectedCaptionId = usePlayerStore((s) => s.caption.selected?.id); @@ -124,7 +130,11 @@ export function OpenSubtitlesCaptionView({ id }: { id: string }) { return ( <> - router.navigate("/captions")}> + + router.navigate(overlayBackLink ? "/captionsOverlay" : "/captions") + } + > {t("player.menus.subtitles.OpenSubtitlesChoice")} diff --git a/src/pages/parts/player/PlayerPart.tsx b/src/pages/parts/player/PlayerPart.tsx index 1f55013b..f012f8ea 100644 --- a/src/pages/parts/player/PlayerPart.tsx +++ b/src/pages/parts/player/PlayerPart.tsx @@ -111,7 +111,10 @@ export function PlayerPart(props: PlayerPartProps) { ) : null} {status === playerStatus.PLAYBACK_ERROR || status === playerStatus.PLAYING ? ( - + <> + + + > ) : null} @@ -121,7 +124,12 @@ export function PlayerPart(props: PlayerPartProps) { {status === playerStatus.PLAYING ? : null} - {status === playerStatus.PLAYING ? : null} + {status === playerStatus.PLAYING ? ( + <> + + + > + ) : null}