From 256f9f9df90df04c3236e09481f53222693a9fba Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Tue, 5 Mar 2024 00:33:31 +0200 Subject: [PATCH] feat: add season/episode to the start of title --- .../internals/{MediaSession.ts => MediaSession.tsx} | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) rename src/components/player/internals/{MediaSession.ts => MediaSession.tsx} (93%) diff --git a/src/components/player/internals/MediaSession.ts b/src/components/player/internals/MediaSession.tsx similarity index 93% rename from src/components/player/internals/MediaSession.ts rename to src/components/player/internals/MediaSession.tsx index e5127c0e..1dc7e737 100644 --- a/src/components/player/internals/MediaSession.ts +++ b/src/components/player/internals/MediaSession.tsx @@ -104,9 +104,15 @@ export function MediaSession() { ) return; - const title = data.meta?.episode?.title ?? data.meta?.title ?? ""; - const artist = - data.meta?.type === "movie" ? undefined : data.meta?.title ?? ""; + let title: string | undefined; + let artist: string | undefined; + + if (data.meta?.type === "movie") { + title = data.meta?.title; + } else if (data.meta?.type === "show") { + artist = data.meta?.title; + title = `S${data.meta?.season?.number} E${data.meta?.episode?.number}: ${data.meta?.episode?.title}`; + } navigator.mediaSession.metadata = new MediaMetadata({ title, @@ -170,6 +176,7 @@ export function MediaSession() { data.meta?.title, data.meta?.type, data.meta?.poster, + data.meta?.season?.number, ]); return null; }