type number to track title
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user