From 20b8a7267827e3a07c1eef668c3b9c22fda43765 Mon Sep 17 00:00:00 2001 From: Factiven Date: Tue, 26 Sep 2023 23:35:35 +0700 Subject: Update v4.1.2 --- pages/en/anime/watch/[...info].js | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'pages/en/anime/watch') diff --git a/pages/en/anime/watch/[...info].js b/pages/en/anime/watch/[...info].js index f5b4fce..b74a3f2 100644 --- a/pages/en/anime/watch/[...info].js +++ b/pages/en/anime/watch/[...info].js @@ -4,7 +4,7 @@ import { FlagIcon, ShareIcon } from "@heroicons/react/24/solid"; import Details from "@/components/watch/primary/details"; import EpisodeLists from "@/components/watch/secondary/episodeLists"; import { getServerSession } from "next-auth"; -import { useWatchProvider } from "@/lib/hooks/watchPageProvider"; +import { useWatchProvider } from "@/lib/context/watchPageProvider"; import { authOptions } from "../../../api/auth/[...nextauth]"; import { createList, createUser, getEpisode } from "@/prisma/user"; import Link from "next/link"; @@ -289,6 +289,29 @@ export default function Watch({ }; }, [provider, watchId, info?.id]); + useEffect(() => { + const mediaSession = navigator.mediaSession; + if (!mediaSession) return; + + const now = episodeNavigation?.playing; + const poster = now?.img || info?.bannerImage; + const title = now?.title || info?.title?.romaji; + + const artwork = poster + ? [{ src: poster, sizes: "512x512", type: "image/jpeg" }] + : undefined; + + mediaSession.metadata = new MediaMetadata({ + title: title, + artist: `Moopa ${ + title === info?.title?.romaji + ? "- Episode " + epiNumber + : `- ${info?.title?.romaji || info?.title?.english}` + }`, + artwork, + }); + }, [episodeNavigation, info, epiNumber]); + const handleShareClick = async () => { try { if (navigator.share) { @@ -338,7 +361,6 @@ export default function Watch({ - + - +