Add effect to set media session metadata (#3713)
This commit is contained in:
parent
8dd43ea6cc
commit
56eef2e601
@ -21,7 +21,7 @@ export const TitleNotifier: FC<TitleNotifierProps> = ({ name }) => {
|
|||||||
const [backgrounded, setBackgrounded] = useState(false);
|
const [backgrounded, setBackgrounded] = useState(false);
|
||||||
const [title, setTitle] = useState(name);
|
const [title, setTitle] = useState(name);
|
||||||
|
|
||||||
const { online } = serverStatus;
|
const { online, streamTitle } = serverStatus;
|
||||||
|
|
||||||
const onBlur = () => {
|
const onBlur = () => {
|
||||||
setBackgrounded(true);
|
setBackgrounded(true);
|
||||||
@ -66,6 +66,17 @@ export const TitleNotifier: FC<TitleNotifierProps> = ({ name }) => {
|
|||||||
setTitle(`💬 :: ${name}`);
|
setTitle(`💬 :: ${name}`);
|
||||||
}, [chatMessages, name]);
|
}, [chatMessages, name]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (navigator.mediaSession === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
navigator.mediaSession.metadata = new MediaMetadata({
|
||||||
|
title: streamTitle,
|
||||||
|
artist: name,
|
||||||
|
artwork: [{ src: '/logo' }],
|
||||||
|
});
|
||||||
|
}, [name, streamTitle]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!backgrounded) {
|
if (!backgrounded) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user