Add effect to set media session metadata (#3713)

This commit is contained in:
mahmed2000 2024-04-20 02:01:50 +05:00 committed by GitHub
parent 8dd43ea6cc
commit 56eef2e601
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,7 +21,7 @@ export const TitleNotifier: FC<TitleNotifierProps> = ({ 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<TitleNotifierProps> = ({ 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;