From 42d8e8fa8ddd9ddcf56bc01e261f839dfe220447 Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Fri, 6 Feb 2026 06:44:45 -0800 Subject: [PATCH] type number to track title --- src/lib/player/media-session.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/lib/player/media-session.ts b/src/lib/player/media-session.ts index a97fa2d..bee2f66 100644 --- a/src/lib/player/media-session.ts +++ b/src/lib/player/media-session.ts @@ -82,16 +82,23 @@ export function createMediaSessionBindings( return; } - const songTypeMap = { - "0": "UNKNOWN", - "1": "OP", - "2": "ED", - "3": "INS", - }; + function typeNumberLabel(t: Track) { + const type = t.type; + const n = Number(t.number ?? 0); + + let typeLabel: string | null = null; + if (typeof type === "number") { + if (type === 1) typeLabel = "OP"; + else if (type === 2) typeLabel = "ED"; + else if (type === 3) typeLabel = "INS"; + else typeLabel = `T${type}`; + } + + if (!typeLabel) return null; + return `${typeLabel}${n ? String(n) : ""}`; + } mediaSession.metadata = new MediaMetadata({ - title: - track.animeName + - ` (${songTypeMap[track.type || "0"] ?? ""}${track.number ?? ""}) — ${track.title}`, + title: ` ${typeNumberLabel(track)} — ${track.title}`, artist: track.artist, album: track.album, // You can add artwork later if/when you have it: