type number to track title

This commit is contained in:
2026-02-06 06:44:45 -08:00
parent d5ed0e251c
commit 42d8e8fa8d

View File

@@ -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: