From 9a56c71e30e519d17bf5e0fcd0baed66ad3e4230 Mon Sep 17 00:00:00 2001 From: TechyGiraffe999 <92249532+TecEash1@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:08:55 +0000 Subject: [PATCH] Add Watch Party Option --- .../player/atoms/settings/Downloads.tsx | 2 +- .../player/atoms/settings/SettingsMenu.tsx | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/player/atoms/settings/Downloads.tsx b/src/components/player/atoms/settings/Downloads.tsx index 8088ff45..1c018b3e 100644 --- a/src/components/player/atoms/settings/Downloads.tsx +++ b/src/components/player/atoms/settings/Downloads.tsx @@ -10,7 +10,7 @@ import { convertSubtitlesToSrtDataurl } from "@/components/player/utils/captions import { useOverlayRouter } from "@/hooks/useOverlayRouter"; import { usePlayerStore } from "@/stores/player/store"; -function useDownloadLink() { +export function useDownloadLink() { const source = usePlayerStore((s) => s.source); const currentQuality = usePlayerStore((s) => s.currentQuality); const url = useMemo(() => { diff --git a/src/components/player/atoms/settings/SettingsMenu.tsx b/src/components/player/atoms/settings/SettingsMenu.tsx index 8321c562..ce03af29 100644 --- a/src/components/player/atoms/settings/SettingsMenu.tsx +++ b/src/components/player/atoms/settings/SettingsMenu.tsx @@ -12,7 +12,10 @@ import { qualityToString } from "@/stores/player/utils/qualities"; import { useSubtitleStore } from "@/stores/subtitles"; import { getPrettyLanguageNameFromLocale } from "@/utils/language"; +import { useDownloadLink } from "./Downloads"; + export function SettingsMenu({ id }: { id: string }) { + const downloadUrl = useDownloadLink(); const { t } = useTranslation(); const router = useOverlayRouter(id); const currentQuality = usePlayerStore((s) => s.currentQuality); @@ -39,6 +42,14 @@ export function SettingsMenu({ id }: { id: string }) { const downloadable = source?.type === "file" || source?.type === "hls"; + const handleWatchPartyClick = () => { + if (downloadUrl) { + const watchPartyUrl = `https://www.watchparty.me/create?video=${encodeURIComponent( + downloadUrl, + )}`; + window.open(watchPartyUrl); + } + }; return ( @@ -67,6 +78,14 @@ export function SettingsMenu({ id }: { id: string }) { > {t("player.menus.settings.downloadItem")} + } + className={downloadable ? "opacity-100" : "opacity-50"} + > + {t("Watch Party")} +