From 56eef2e60151b404b730e089d4b09a5d44e69f68 Mon Sep 17 00:00:00 2001 From: mahmed2000 Date: Sat, 20 Apr 2024 02:01:50 +0500 Subject: [PATCH] Add effect to set media session metadata (#3713) --- web/components/TitleNotifier/TitleNotifier.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/components/TitleNotifier/TitleNotifier.tsx b/web/components/TitleNotifier/TitleNotifier.tsx index a6f3dce62..e69c7fad0 100644 --- a/web/components/TitleNotifier/TitleNotifier.tsx +++ b/web/components/TitleNotifier/TitleNotifier.tsx @@ -21,7 +21,7 @@ export const TitleNotifier: FC = ({ name }) => { const [backgrounded, setBackgrounded] = useState(false); const [title, setTitle] = useState(name); - const { online } = serverStatus; + const { online, streamTitle } = serverStatus; const onBlur = () => { setBackgrounded(true); @@ -66,6 +66,17 @@ export const TitleNotifier: FC = ({ name }) => { setTitle(`💬 :: ${name}`); }, [chatMessages, name]); + useEffect(() => { + if (navigator.mediaSession === undefined) { + return; + } + navigator.mediaSession.metadata = new MediaMetadata({ + title: streamTitle, + artist: name, + artwork: [{ src: '/logo' }], + }); + }, [name, streamTitle]); + useEffect(() => { if (!backgrounded) { return;