1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

Merge pull request #3 from TecEash1/main

Add Watch Party Option
This commit is contained in:
sudo-flix 2024-03-16 14:14:09 -04:00 committed by GitHub
commit 0e07711b6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -10,7 +10,7 @@ import { convertSubtitlesToSrtDataurl } from "@/components/player/utils/captions
import { useOverlayRouter } from "@/hooks/useOverlayRouter"; import { useOverlayRouter } from "@/hooks/useOverlayRouter";
import { usePlayerStore } from "@/stores/player/store"; import { usePlayerStore } from "@/stores/player/store";
function useDownloadLink() { export function useDownloadLink() {
const source = usePlayerStore((s) => s.source); const source = usePlayerStore((s) => s.source);
const currentQuality = usePlayerStore((s) => s.currentQuality); const currentQuality = usePlayerStore((s) => s.currentQuality);
const url = useMemo(() => { const url = useMemo(() => {

View file

@ -12,7 +12,10 @@ import { qualityToString } from "@/stores/player/utils/qualities";
import { useSubtitleStore } from "@/stores/subtitles"; import { useSubtitleStore } from "@/stores/subtitles";
import { getPrettyLanguageNameFromLocale } from "@/utils/language"; import { getPrettyLanguageNameFromLocale } from "@/utils/language";
import { useDownloadLink } from "./Downloads";
export function SettingsMenu({ id }: { id: string }) { export function SettingsMenu({ id }: { id: string }) {
const downloadUrl = useDownloadLink();
const { t } = useTranslation(); const { t } = useTranslation();
const router = useOverlayRouter(id); const router = useOverlayRouter(id);
const currentQuality = usePlayerStore((s) => s.currentQuality); 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 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 ( return (
<Menu.Card> <Menu.Card>
<Menu.SectionTitle> <Menu.SectionTitle>
@ -67,6 +78,14 @@ export function SettingsMenu({ id }: { id: string }) {
> >
{t("player.menus.settings.downloadItem")} {t("player.menus.settings.downloadItem")}
</Menu.Link> </Menu.Link>
<Menu.Link
clickable
onClick={handleWatchPartyClick}
rightSide={<Icon className="text-xl" icon={Icons.WATCH_PARTY} />}
className={downloadable ? "opacity-100" : "opacity-50"}
>
{t("Watch Party")}
</Menu.Link>
</Menu.Section> </Menu.Section>
<Menu.SectionTitle> <Menu.SectionTitle>