mirror of
https://github.com/pvrzz/atmosphere.git
synced 2026-11-29 05:22:26 +00:00
Responsive mini player, set details, cleaner titles, featured artists
- Mini player reflows by size: portrait card, wide strip with art left and controls right, or tiny - Lyrics preview in the mini player when there's room; lyrics and queue are exclusive - Mini player can't be maximised and remembers its size - SoundCloud sets read track details in parallel and split "Artist - Title" - YouTube titles drop (Official Music Video) and similar tags; Topic/VEVO channels become the artist - Comma lists and feat. credits in titles count as separate artists - Artist profiles show Featured on with the release type and which song - Downloaded files keep the source description and link in their notes - Opus is labelled Opus; DRC-compressed YouTube audio is avoided
This commit is contained in:
@@ -40,6 +40,7 @@ const PLATFORM_ICON = [
|
||||
[/(^|\.)x\.com|twitter\.com/i, "brand-x", "X"],
|
||||
[/instagram\.com/i, "brand-instagram", "Instagram"],
|
||||
];
|
||||
const codecName = (c) => ({ opus: "Opus", vorbis: "Vorbis", mp4a: "AAC", aac: "AAC", pcm: "PCM" })[(c || "").toLowerCase()] || (c || "").toUpperCase();
|
||||
const platformIcon = (name) => (PLATFORM_ICON.find((p) => p[2] === name) || [0, "world"])[1];
|
||||
|
||||
const state = {
|
||||
@@ -600,7 +601,7 @@ function defaults(c, e) {
|
||||
isrc: "",
|
||||
bpm: null,
|
||||
key: "",
|
||||
comment: "",
|
||||
comment: [e.description?.trim(), e.url ? `Source: ${e.url}` : ""].filter(Boolean).join("\n\n"),
|
||||
lyrics: e.lyrics || "",
|
||||
artwork: rel || c.data.single ? c.album.artwork : { kind: "keep" },
|
||||
};
|
||||
@@ -999,7 +1000,7 @@ function inspector(c, e, inline) {
|
||||
function availabilityFlags(e) {
|
||||
if (!e.media) return [h("span", { class: "flag" }, e.detailed ? "Unknown formats" : "Checking…")];
|
||||
const m = e.media, out = [];
|
||||
if (m.bestCodec) out.push(h("span", { class: "flag" }, `${m.bestCodec.toUpperCase()}${m.bestAbr ? ` ${m.bestAbr} kbps` : ""} best audio`));
|
||||
if (m.bestCodec) out.push(h("span", { class: "flag" }, `${codecName(m.bestCodec)}${m.bestAbr ? ` ${m.bestAbr} kbps` : ""} best audio`));
|
||||
if (m.original) out.push(h("span", { class: "flag" }, `Original ${m.originalExt ? m.originalExt.toUpperCase() : "file"}`));
|
||||
if (m.lossless) out.push(h("span", { class: "flag" }, "Lossless source"));
|
||||
if (m.hasVideo) out.push(h("span", { class: "flag" }, m.heights.length ? `Video up to ${m.heights[0]}p` : "Video"));
|
||||
@@ -1020,7 +1021,7 @@ function selectionCaps(c) {
|
||||
const lossless = known.some((e) => e.media.lossless || (e.media.original && e.media.originalLossless));
|
||||
const originals = known.filter((e) => e.media.original).length;
|
||||
const heights = [...new Set(known.flatMap((e) => e.media.heights || []))].sort((a, b) => b - a);
|
||||
const codecs = [...new Set(known.map((e) => e.media.bestCodec && `${e.media.bestCodec.toUpperCase()}${e.media.bestAbr ? ` ${e.media.bestAbr} kbps` : ""}`).filter(Boolean))];
|
||||
const codecs = [...new Set(known.map((e) => e.media.bestCodec && `${codecName(e.media.bestCodec)}${e.media.bestAbr ? ` ${e.media.bestAbr} kbps` : ""}`).filter(Boolean))];
|
||||
return {
|
||||
count: ents.length,
|
||||
unknown: known.length < ents.length,
|
||||
|
||||
+60
-5
@@ -19,8 +19,27 @@ const Lib = {
|
||||
};
|
||||
|
||||
const lnorm = (s) => (s || "").trim().toLowerCase();
|
||||
const primaryArtist = (s) => (s || "").split(/\s*(?:,|;|\bfeat\.?|\bft\.?|\bfeaturing\b)\s*/i)[0].trim() || "Unknown artist";
|
||||
const artistsOf = (t) => [...new Set([t.albumArtist, ...(t.artist || "").split(/\s*(?:,|;|\bfeat\.?|\bft\.?|\bfeaturing\b)\s*/i)].map((x) => (x || "").trim()).filter(Boolean))];
|
||||
function splitNames(s) {
|
||||
const text = (s || "").trim();
|
||||
let parts = text.split(/\s*(?:,|;|\s(?:feat\.?|ft\.?|featuring)\s|^(?:feat\.?|ft\.?)\s)\s*/i);
|
||||
if (/,/.test(text)) parts = parts.flatMap((p) => p.split(/\s+&\s+/));
|
||||
return parts.map((p) => p.trim()).filter(Boolean);
|
||||
}
|
||||
function titleCredits(title) {
|
||||
const t = title || "";
|
||||
const inBrackets = [...t.matchAll(/[\(\[]\s*(?:feat\.?|ft\.?|featuring|with)\s+([^\)\]]+)[\)\]]/gi)].map((m) => m[1]);
|
||||
const trailing = t.match(/\s(?:feat\.?|ft\.?|featuring)\s+([^\(\[]+)$/i);
|
||||
return [...inBrackets, trailing?.[1]].filter(Boolean).flatMap((x) => splitNames(x.replace(/,?\s+&\s+/g, ", ")));
|
||||
}
|
||||
const primaryArtist = (s) => splitNames(s)[0] || "Unknown artist";
|
||||
const artistsOf = (t) => {
|
||||
const seen = new Map();
|
||||
for (const n of [t.albumArtist, ...splitNames(t.artist), ...titleCredits(t.title)]) {
|
||||
const k = lnorm(n);
|
||||
if (k && !seen.has(k)) seen.set(k, n.trim());
|
||||
}
|
||||
return [...seen.values()];
|
||||
};
|
||||
const sig = (t) => `${lnorm(t.title)}|${lnorm(primaryArtist(t.artist))}|${Math.round((t.durationMs || 0) / 2000)}`;
|
||||
const albumKind = (a) => {
|
||||
const mins = a.duration / 60000;
|
||||
@@ -52,7 +71,7 @@ function buildIndexes(snap) {
|
||||
const artists = new Map();
|
||||
const touch = (name) => {
|
||||
const k = lnorm(name);
|
||||
if (!artists.has(k)) artists.set(k, { key: k, name, meta: metaByName.get(k) || null, albums: [], tracks: [], appearsOn: [] });
|
||||
if (!artists.has(k)) artists.set(k, { key: k, name, meta: metaByName.get(k) || null, albums: [], tracks: [], appearsOn: [], featured: [] });
|
||||
return artists.get(k);
|
||||
};
|
||||
for (const a of albums.values()) touch(a.artist).albums.push(a);
|
||||
@@ -63,7 +82,33 @@ function buildIndexes(snap) {
|
||||
if (ar && lnorm(a.artist) !== ar.key && !ar.appearsOn.includes(a)) ar.appearsOn.push(a);
|
||||
}
|
||||
}
|
||||
for (const ar of artists.values()) ar.albums.sort((x, y) => (y.year || 0) - (x.year || 0));
|
||||
for (const a of albums.values()) {
|
||||
const byArtist = new Map();
|
||||
for (const t of a.tracks) {
|
||||
for (const n of artistsOf(t)) {
|
||||
const k = lnorm(n);
|
||||
if (k === lnorm(a.artist)) continue;
|
||||
if (!byArtist.has(k)) byArtist.set(k, []);
|
||||
byArtist.get(k).push(t);
|
||||
}
|
||||
}
|
||||
for (const [k, tracks] of byArtist) {
|
||||
const ar = artists.get(k);
|
||||
if (ar) ar.featured.push({ kind: albumKind(a), title: a.title, by: a.artist, art: a.art, year: a.year, on: tracks.map((t) => t.title), album: a });
|
||||
}
|
||||
}
|
||||
for (const t of Lib.songs) {
|
||||
if (t.album) continue;
|
||||
const main = lnorm(primaryArtist(t.artist));
|
||||
for (const n of artistsOf(t)) {
|
||||
const ar = artists.get(lnorm(n));
|
||||
if (ar && ar.key !== main) ar.featured.push({ kind: "Song", title: t.title, by: primaryArtist(t.artist), art: t.art, year: t.year, on: [], track: t });
|
||||
}
|
||||
}
|
||||
for (const ar of artists.values()) {
|
||||
ar.albums.sort((x, y) => (y.year || 0) - (x.year || 0));
|
||||
ar.featured.sort((x, y) => (y.year || 0) - (x.year || 0) || x.title.localeCompare(y.title));
|
||||
}
|
||||
Lib.artists = artists;
|
||||
}
|
||||
|
||||
@@ -561,6 +606,16 @@ function songsView(root) {
|
||||
requestAnimationFrame(draw);
|
||||
}
|
||||
|
||||
function featuredCard(f) {
|
||||
const open = () => (f.album ? openLib("album", f.album.key) : playList([f.track]));
|
||||
const onLine = f.on.length && !(f.on.length === 1 && lnorm(f.on[0]) === lnorm(f.title)) ? `on ${f.on.slice(0, 2).join(", ")}${f.on.length > 2 ? ` +${f.on.length - 2}` : ""}` : "";
|
||||
return h("div", { class: "card-tile", role: "button", tabindex: "0", "data-album": f.album?.key || null, onclick: open, onkeydown: (e) => { if (e.key === "Enter") open(); } },
|
||||
h("div", { class: "tile-art" }, cover(f.art, "tile-img", f.title), h("button", { class: "tile-play", "aria-label": `Play ${f.title}`, onclick: (e) => { e.stopPropagation(); playList(f.album ? f.album.tracks : [f.track]); } }, icon("player-play-filled"))),
|
||||
h("div", { class: "tile-title" }, f.title),
|
||||
h("div", { class: "tile-sub" }, h("span", { class: "tile-kind" }, f.kind), ` · ${f.by}`),
|
||||
onLine ? h("div", { class: "tile-sub on" }, onLine) : null);
|
||||
}
|
||||
|
||||
function albumCard(a) {
|
||||
return h("div", { class: "card-tile", role: "button", tabindex: "0", "data-album": a.key, onclick: () => openLib("album", a.key), onkeydown: (e) => { if (e.key === "Enter") openLib("album", a.key); } },
|
||||
h("div", { class: "tile-art" }, cover(a.art, "tile-img", a.title), h("button", { class: "tile-play", "aria-label": `Play ${a.title}`, onclick: (e) => { e.stopPropagation(); playList(a.tracks); } }, icon("player-play-filled"))),
|
||||
@@ -641,7 +696,7 @@ function artistView(root, key) {
|
||||
body.append(h("section", {}, h("h2", { class: "sec" }, "Popular"), trackList(popular, { cover: true, list: popular })));
|
||||
if (full.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Albums"), h("div", { class: "grid" }, ...full.map(albumCard))));
|
||||
if (small.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Singles & EPs"), h("div", { class: "grid" }, ...small.map(albumCard))));
|
||||
if (ar.appearsOn.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Appears on"), h("div", { class: "grid" }, ...ar.appearsOn.map(albumCard))));
|
||||
if (ar.featured.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Featured on"), h("div", { class: "grid" }, ...ar.featured.map(featuredCard))));
|
||||
body.append(h("section", { class: "about" }, h("h2", { class: "sec" }, "About"), ar.meta?.bio ? h("p", { class: "bio" }, ar.meta.bio) : h("button", { class: "link muted", onclick: () => editArtist(ar) }, "Add a bio and photo for this artist")));
|
||||
root.append(body);
|
||||
}
|
||||
|
||||
+2
-1
@@ -152,11 +152,12 @@ function openLyrics() {
|
||||
function renderLyricsAll() {
|
||||
renderLyricsPanel();
|
||||
if (Lyr.tv) renderTv();
|
||||
if (typeof Mini !== "undefined" && Mini.on) renderMiniPanel();
|
||||
}
|
||||
|
||||
function tick() {
|
||||
Lyr.raf = 0;
|
||||
const visible = !$("#lyricsPanel").hidden || Lyr.tv;
|
||||
const visible = !$("#lyricsPanel").hidden || Lyr.tv || (typeof Mini !== "undefined" && Mini.on && Mini.panelShown && Mini.prefs.panel === "lyrics");
|
||||
if (!visible) return;
|
||||
const l = Lyr.data;
|
||||
if (l?.synced) {
|
||||
|
||||
+210
-65
@@ -1,19 +1,27 @@
|
||||
// atmosphere · miniplayer.js · Compact always-on-top player with optional cover, blurred backdrop and an editable queue
|
||||
// atmosphere · miniplayer.js · Compact always-on-top player that reflows by size: portrait card, wide strip or tiny, with a lyrics or queue panel when there's room
|
||||
const Mini = {
|
||||
on: false,
|
||||
restore: null,
|
||||
prefs: { cover: true, blur: true, queue: false, pin: true },
|
||||
prefs: { cover: true, blur: true, panel: "none", pin: true },
|
||||
dragFrom: null,
|
||||
layout: "",
|
||||
panelShown: false,
|
||||
sizeTimer: 0,
|
||||
lyricsFor: null,
|
||||
};
|
||||
|
||||
const MINI_W = 340;
|
||||
const MINI_BASE = 168;
|
||||
const MINI_COVER = 300;
|
||||
const MINI_QUEUE = 232;
|
||||
const MINI_MIN = { w: 260, h: 96 };
|
||||
const MINI_MAX = { w: 900, h: 900 };
|
||||
const MINI_CORE = 168;
|
||||
const MINI_STRIP = 112;
|
||||
const MINI_PANEL = 232;
|
||||
|
||||
function miniLoad() {
|
||||
try {
|
||||
Object.assign(Mini.prefs, JSON.parse(localStorage.getItem("atmo.mini") || "{}"));
|
||||
const saved = JSON.parse(localStorage.getItem("atmo.mini") || "{}");
|
||||
if (saved.queue && !saved.panel) saved.panel = "queue";
|
||||
delete saved.queue;
|
||||
Object.assign(Mini.prefs, saved);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
@@ -23,19 +31,34 @@ function miniSave() {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const miniWin = () => window.__TAURI__?.window?.getCurrentWindow?.();
|
||||
|
||||
function miniHeight() {
|
||||
return MINI_BASE + (Mini.prefs.cover ? MINI_COVER : 0) + (Mini.prefs.queue ? MINI_QUEUE : 0);
|
||||
function miniSavedSize() {
|
||||
try {
|
||||
const s = JSON.parse(localStorage.getItem("atmo.miniSize") || "null");
|
||||
if (s && s.w >= MINI_MIN.w && s.h >= MINI_MIN.h) return s;
|
||||
} catch {}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function miniResize() {
|
||||
const miniWin = () => window.__TAURI__?.window?.getCurrentWindow?.();
|
||||
|
||||
function miniIdealHeight(w, wide) {
|
||||
const panel = Mini.prefs.panel !== "none";
|
||||
if (wide) return MINI_STRIP + (panel ? MINI_PANEL : 0);
|
||||
return MINI_CORE + (Mini.prefs.cover ? Math.min(w - 40, 300) : 0) + (panel ? MINI_PANEL : 0);
|
||||
}
|
||||
|
||||
async function miniSetSize(w, h) {
|
||||
const win = miniWin();
|
||||
const dpi = window.__TAURI__?.dpi;
|
||||
if (!win || !dpi) return;
|
||||
const min = MINI_BASE + (Mini.prefs.queue ? 120 : 0);
|
||||
await win.setMinSize(new dpi.LogicalSize(300, min)).catch(() => {});
|
||||
await win.setSize(new dpi.LogicalSize(MINI_W, miniHeight())).catch(() => {});
|
||||
const cw = Math.max(MINI_MIN.w, Math.min(MINI_MAX.w, Math.round(w)));
|
||||
const ch = Math.max(MINI_MIN.h, Math.min(MINI_MAX.h, Math.round(h)));
|
||||
await win.setSize(new dpi.LogicalSize(cw, ch)).catch(() => {});
|
||||
}
|
||||
|
||||
async function miniFit() {
|
||||
const w = innerWidth;
|
||||
await miniSetSize(w, miniIdealHeight(w, Mini.layout === "wide"));
|
||||
}
|
||||
|
||||
async function openMini() {
|
||||
@@ -45,16 +68,22 @@ async function openMini() {
|
||||
closeFx();
|
||||
Mini.on = true;
|
||||
document.body.classList.add("mini-mode");
|
||||
$("#mini").hidden = false;
|
||||
$("#mini").classList.toggle("mac", isMac);
|
||||
const box = $("#mini");
|
||||
box.hidden = false;
|
||||
box.classList.toggle("mac", isMac);
|
||||
const win = miniWin();
|
||||
if (win) {
|
||||
const dpi = window.__TAURI__?.dpi;
|
||||
if (win && dpi) {
|
||||
Mini.restore = { pos: await win.outerPosition().catch(() => null), size: await win.outerSize().catch(() => null), max: await win.isMaximized().catch(() => false) };
|
||||
if (Mini.restore.max) await win.unmaximize().catch(() => {});
|
||||
await miniResize();
|
||||
await win.setMaximizable(false).catch(() => {});
|
||||
await win.setMinSize(new dpi.LogicalSize(MINI_MIN.w, MINI_MIN.h)).catch(() => {});
|
||||
await win.setMaxSize(new dpi.LogicalSize(MINI_MAX.w, MINI_MAX.h)).catch(() => {});
|
||||
const saved = miniSavedSize();
|
||||
await miniSetSize(saved?.w || 340, saved?.h || miniIdealHeight(340, false));
|
||||
await win.setAlwaysOnTop(!!Mini.prefs.pin).catch(() => {});
|
||||
}
|
||||
renderMini();
|
||||
buildMini();
|
||||
}
|
||||
|
||||
async function closeMini() {
|
||||
@@ -62,12 +91,16 @@ async function closeMini() {
|
||||
Mini.on = false;
|
||||
document.body.classList.remove("mini-mode");
|
||||
$("#mini").hidden = true;
|
||||
$("#mini").replaceChildren();
|
||||
Mini.lyricsFor = null;
|
||||
const win = miniWin();
|
||||
const dpi = window.__TAURI__?.dpi;
|
||||
const r = Mini.restore;
|
||||
Mini.restore = null;
|
||||
if (!win || !dpi) return;
|
||||
await win.setAlwaysOnTop(false).catch(() => {});
|
||||
await win.setMaxSize(null).catch(() => {});
|
||||
await win.setMaximizable(true).catch(() => {});
|
||||
await win.setMinSize(new dpi.LogicalSize(900, 620)).catch(() => {});
|
||||
if (r?.size) await win.setSize(new dpi.PhysicalSize(r.size.width, r.size.height)).catch(() => {});
|
||||
if (r?.pos) await win.setPosition(new dpi.PhysicalPosition(r.pos.x, r.pos.y)).catch(() => {});
|
||||
@@ -75,15 +108,17 @@ async function closeMini() {
|
||||
}
|
||||
|
||||
async function miniToggle(key) {
|
||||
Mini.prefs[key] = !Mini.prefs[key];
|
||||
if (key === "lyrics" || key === "queue") {
|
||||
Mini.prefs.panel = Mini.prefs.panel === key ? "none" : key;
|
||||
} else Mini.prefs[key] = !Mini.prefs[key];
|
||||
miniSave();
|
||||
if (key === "pin") await miniWin()?.setAlwaysOnTop(Mini.prefs.pin).catch(() => {});
|
||||
if (key === "cover" || key === "queue") await miniResize();
|
||||
renderMini();
|
||||
const needsFit = key === "lyrics" || key === "queue" || (key === "cover" && Mini.layout !== "wide");
|
||||
buildMini();
|
||||
if (needsFit) await miniFit();
|
||||
}
|
||||
|
||||
function miniButton(key, iconName, label) {
|
||||
const on = !!Mini.prefs[key];
|
||||
function miniButton(key, iconName, label, on) {
|
||||
return h("button", { class: "icon-btn mini-opt", "aria-pressed": String(on), "aria-label": label, title: label, onclick: () => miniToggle(key) }, icon(iconName));
|
||||
}
|
||||
|
||||
@@ -129,56 +164,143 @@ function moveInQueue(from, to) {
|
||||
Player.persist();
|
||||
}
|
||||
|
||||
function renderMini() {
|
||||
function buildMini() {
|
||||
const box = $("#mini");
|
||||
if (!box || !Mini.on) return;
|
||||
const t = Player.current;
|
||||
const art = t?.art ? artUrl(t.art) : null;
|
||||
box.classList.toggle("with-cover", !!Mini.prefs.cover);
|
||||
box.classList.toggle("with-blur", !!Mini.prefs.blur && !!art);
|
||||
box.classList.toggle("with-queue", !!Mini.prefs.queue);
|
||||
box.style.setProperty("--mini-art", art ? `url("${art}")` : "none");
|
||||
const playing = !Player.audio.paused;
|
||||
const next = Player.queue.slice(Player.index + 1);
|
||||
const parts = [
|
||||
h("div", { class: "mini-bg", "aria-hidden": "true" }),
|
||||
h("div", { class: "mini-top", "data-tauri-drag-region": "" },
|
||||
h("span", { class: "mini-brand", "data-tauri-drag-region": "" }, "Atmosphere"),
|
||||
h("div", { class: "mini-opts" },
|
||||
miniButton("cover", "photo", Mini.prefs.cover ? "Hide cover art" : "Show cover art"),
|
||||
miniButton("blur", "droplet", Mini.prefs.blur ? "Turn off blurred backdrop" : "Blurred cover backdrop"),
|
||||
miniButton("queue", "list", Mini.prefs.queue ? "Hide queue" : "Show queue"),
|
||||
miniButton("pin", Mini.prefs.pin ? "pinned" : "pin", Mini.prefs.pin ? "Always on top: on" : "Always on top: off"),
|
||||
h("button", { class: "icon-btn", "aria-label": "Back to full window", title: "Back to full window (P)", onclick: closeMini }, icon("arrows-maximize")))),
|
||||
Mini.prefs.cover ? h("div", { class: "mini-art", "data-tauri-drag-region": "" }, art ? h("img", { src: art, alt: "", draggable: "false", "data-tauri-drag-region": "" }) : h("div", { class: "mini-art-empty" }, icon("music"))) : null,
|
||||
h("div", { class: "mini-meta" },
|
||||
h("span", { class: "mini-title", title: t?.title || "" }, t?.title || "Nothing playing"),
|
||||
h("span", { class: "mini-artist" }, t?.artist || "Pick something from your library")),
|
||||
h("div", { class: "mini-seek" },
|
||||
h("span", { class: "mini-t", id: "miniCur" }, "0:00"),
|
||||
h("input", { type: "range", class: "range", id: "miniSeek", min: "0", max: "1000", value: "0", "aria-label": "Seek" }),
|
||||
h("span", { class: "mini-t", id: "miniDur" }, "0:00")),
|
||||
h("div", { class: "mini-ctl" },
|
||||
h("button", { class: "icon-btn", "aria-label": "Previous", onclick: () => Player.prev() }, icon("player-skip-back-filled")),
|
||||
h("button", { class: "mini-play", "aria-label": playing ? "Pause" : "Play", onclick: () => Player.toggle() }, icon(playing ? "player-pause-filled" : "player-play-filled")),
|
||||
h("button", { class: "icon-btn", "aria-label": "Next", onclick: () => Player.next() }, icon("player-skip-forward-filled"))),
|
||||
Mini.prefs.queue
|
||||
? h("div", { class: "mini-queue" },
|
||||
h("div", { class: "mq-head" }, h("span", {}, next.length ? `Up next · ${next.length}` : "Up next"), next.length ? h("button", { class: "btn small ghost", onclick: () => Player.clearUpNext() }, "Clear") : null),
|
||||
next.length ? h("div", { class: "mq-list" }, ...next.slice(0, 200).map((q, k) => miniQueueRow(q, Player.index + 1 + k))) : h("p", { class: "mq-empty" }, "Nothing queued. Add songs from your library."))
|
||||
: null,
|
||||
];
|
||||
box.replaceChildren(...parts.filter(Boolean));
|
||||
const seek = $("#miniSeek");
|
||||
const p = Mini.prefs;
|
||||
box.classList.toggle("with-cover", !!p.cover);
|
||||
const art = h("div", { class: "mini-art", "data-tauri-drag-region": "" });
|
||||
const seek = h("input", { type: "range", class: "range", id: "miniSeek", min: "0", max: "1000", value: "0", "aria-label": "Seek" });
|
||||
seek.addEventListener("input", () => {
|
||||
rangeFill(seek);
|
||||
const d = Player.audio.duration;
|
||||
if (isFinite(d)) $("#miniCur").textContent = fmtDur((seek.value / 1000) * d * 1000);
|
||||
});
|
||||
seek.addEventListener("change", () => Player.seek((seek.value / 1000) * Player.audio.duration));
|
||||
box.replaceChildren(
|
||||
h("div", { class: "mini-bg", "aria-hidden": "true" }),
|
||||
h("div", { class: "mini-top", "data-tauri-drag-region": "" },
|
||||
h("span", { class: "mini-brand", "data-tauri-drag-region": "" }, "Atmosphere"),
|
||||
h("div", { class: "mini-opts" },
|
||||
miniButton("cover", "photo", p.cover ? "Hide cover art" : "Show cover art", p.cover),
|
||||
miniButton("blur", "droplet", p.blur ? "Turn off blurred backdrop" : "Blurred cover backdrop", p.blur),
|
||||
miniButton("lyrics", "microphone", p.panel === "lyrics" ? "Hide lyrics" : "Show lyrics", p.panel === "lyrics"),
|
||||
miniButton("queue", "list", p.panel === "queue" ? "Hide queue" : "Show queue", p.panel === "queue"),
|
||||
miniButton("pin", p.pin ? "pinned" : "pin", p.pin ? "Always on top: on" : "Always on top: off", p.pin),
|
||||
h("button", { class: "icon-btn", "aria-label": "Back to full window", title: "Back to full window (P)", onclick: closeMini }, icon("arrows-maximize")))),
|
||||
h("div", { class: "mini-body", "data-tauri-drag-region": "" },
|
||||
art,
|
||||
h("div", { class: "mini-info", "data-tauri-drag-region": "" },
|
||||
h("div", { class: "mini-meta", "data-tauri-drag-region": "" },
|
||||
h("span", { class: "mini-title", id: "miniTitle", "data-tauri-drag-region": "" }),
|
||||
h("span", { class: "mini-artist", id: "miniArtist", "data-tauri-drag-region": "" })),
|
||||
h("div", { class: "mini-seek" }, h("span", { class: "mini-t", id: "miniCur" }, "0:00"), seek, h("span", { class: "mini-t", id: "miniDur" }, "0:00"))),
|
||||
h("div", { class: "mini-ctl" },
|
||||
h("button", { class: "icon-btn", "aria-label": "Previous", onclick: () => Player.prev() }, icon("player-skip-back-filled")),
|
||||
h("button", { class: "mini-play", id: "miniPlay", onclick: () => Player.toggle() }),
|
||||
h("button", { class: "icon-btn", "aria-label": "Next", onclick: () => Player.next() }, icon("player-skip-forward-filled")))),
|
||||
h("div", { class: "mini-panel", id: "miniPanel" })
|
||||
);
|
||||
Mini.lyricsFor = null;
|
||||
Mini.layout = "";
|
||||
miniLayout();
|
||||
updateMini();
|
||||
renderMiniPanel();
|
||||
}
|
||||
|
||||
function updateMini() {
|
||||
const box = $("#mini");
|
||||
if (!box || !Mini.on || !$("#miniTitle")) return;
|
||||
const t = Player.current;
|
||||
const art = t?.art ? artUrl(t.art) : null;
|
||||
box.classList.toggle("with-blur", !!Mini.prefs.blur && !!art);
|
||||
box.style.setProperty("--mini-art", art ? `url("${art}")` : "none");
|
||||
$("#miniTitle").textContent = t?.title || "Nothing playing";
|
||||
$("#miniTitle").title = t?.title || "";
|
||||
$("#miniArtist").textContent = t?.artist || "Pick something from your library";
|
||||
const artBox = box.querySelector(".mini-art");
|
||||
const img = artBox.querySelector("img");
|
||||
if (art && img?.getAttribute("src") !== art) artBox.replaceChildren(h("img", { src: art, alt: "", draggable: "false", "data-tauri-drag-region": "" }));
|
||||
else if (!art && !artBox.querySelector(".mini-art-empty")) artBox.replaceChildren(h("div", { class: "mini-art-empty", "data-tauri-drag-region": "" }, icon("music")));
|
||||
const playing = !Player.audio.paused;
|
||||
const pb = $("#miniPlay");
|
||||
pb.setAttribute("aria-label", playing ? "Pause" : "Play");
|
||||
pb.replaceChildren(icon(playing ? "player-pause-filled" : "player-play-filled"));
|
||||
miniTime();
|
||||
}
|
||||
|
||||
function renderMiniPanel() {
|
||||
const panel = $("#miniPanel");
|
||||
if (!panel || !Mini.on) return;
|
||||
const kind = Mini.panelShown ? Mini.prefs.panel : "none";
|
||||
panel.dataset.kind = kind;
|
||||
if (kind === "queue") {
|
||||
Mini.lyricsFor = null;
|
||||
const next = Player.queue.slice(Player.index + 1);
|
||||
panel.replaceChildren(
|
||||
h("div", { class: "mq-head" }, h("span", {}, next.length ? `Up next · ${next.length}` : "Up next"), next.length ? h("button", { class: "btn small ghost", onclick: () => Player.clearUpNext() }, "Clear") : null),
|
||||
next.length ? h("div", { class: "mq-list" }, ...next.slice(0, 200).map((q, k) => miniQueueRow(q, Player.index + 1 + k))) : h("p", { class: "mq-empty" }, "Nothing queued. Add songs from your library."));
|
||||
return;
|
||||
}
|
||||
if (kind !== "lyrics") {
|
||||
Mini.lyricsFor = null;
|
||||
panel.replaceChildren();
|
||||
return;
|
||||
}
|
||||
const t = Player.current;
|
||||
if (t && Lyr.trackId !== t.id) loadLyrics();
|
||||
const key = `${t?.id || ""}|${Lyr.loading}|${!!Lyr.data}|${Lyr.data?.synced}`;
|
||||
if (Mini.lyricsFor === key) return;
|
||||
Mini.lyricsFor = key;
|
||||
let content;
|
||||
if (!t) content = h("p", { class: "mini-lyr-note" }, "Play something to see its lyrics.");
|
||||
else if (Lyr.loading) content = h("p", { class: "mini-lyr-note" }, "Finding lyrics…");
|
||||
else if (!Lyr.data) content = h("p", { class: "mini-lyr-note" }, "No lyrics found for this song.");
|
||||
else {
|
||||
content = h("div", { class: "mini-lyr-scroll" }, lyricLines(Lyr.data, false));
|
||||
Lyr.active = -1;
|
||||
startTick();
|
||||
}
|
||||
panel.replaceChildren(content);
|
||||
}
|
||||
|
||||
function miniLayout() {
|
||||
const box = $("#mini");
|
||||
if (!box || !Mini.on) return;
|
||||
const w = innerWidth;
|
||||
const ht = innerHeight;
|
||||
const tiny = w < 290 || ht < 132;
|
||||
const wide = !tiny && w >= 400 && w >= ht * 1.3;
|
||||
const layout = tiny ? "tiny" : wide ? "wide" : "portrait";
|
||||
const panelWant = Mini.prefs.panel !== "none";
|
||||
let panelShown = false;
|
||||
let artSize = 0;
|
||||
if (layout === "wide") {
|
||||
panelShown = panelWant && ht >= MINI_STRIP + 120;
|
||||
const strip = panelShown ? MINI_STRIP : ht;
|
||||
artSize = Math.max(56, Math.min(strip - 24, Math.round(w * 0.32), 300));
|
||||
} else if (layout === "portrait") {
|
||||
const room = ht - MINI_CORE;
|
||||
panelShown = panelWant && room - (Mini.prefs.cover ? 120 : 0) >= 120;
|
||||
const forArt = room - (panelShown ? Math.max(MINI_PANEL, room * 0.45) : 0);
|
||||
artSize = Mini.prefs.cover ? Math.max(0, Math.min(w - 40, forArt - 14, 420)) : 0;
|
||||
if (artSize < 96) artSize = 0;
|
||||
}
|
||||
box.classList.toggle("wide", layout === "wide");
|
||||
box.classList.toggle("tiny", layout === "tiny");
|
||||
box.classList.toggle("portrait", layout === "portrait");
|
||||
box.classList.toggle("has-panel", panelShown);
|
||||
box.classList.toggle("no-art", !Mini.prefs.cover || (layout === "portrait" && !artSize) || layout === "tiny");
|
||||
box.style.setProperty("--art", `${artSize}px`);
|
||||
const changed = layout !== Mini.layout || panelShown !== Mini.panelShown;
|
||||
Mini.layout = layout;
|
||||
Mini.panelShown = panelShown;
|
||||
if (changed) {
|
||||
Mini.lyricsFor = null;
|
||||
renderMiniPanel();
|
||||
}
|
||||
}
|
||||
|
||||
function miniTime() {
|
||||
if (!Mini.on) return;
|
||||
const seek = $("#miniSeek");
|
||||
@@ -191,6 +313,13 @@ function miniTime() {
|
||||
$("#miniDur").textContent = d ? fmtDur(d * 1000) : "0:00";
|
||||
}
|
||||
|
||||
function renderMini() {
|
||||
if (!Mini.on) return;
|
||||
if (!$("#miniTitle")) return buildMini();
|
||||
updateMini();
|
||||
renderMiniPanel();
|
||||
}
|
||||
|
||||
function bindMini() {
|
||||
miniLoad();
|
||||
$("#miniBtn")?.addEventListener("click", () => (Mini.on ? closeMini() : openMini()));
|
||||
@@ -199,7 +328,23 @@ function bindMini() {
|
||||
const type = e.detail.type;
|
||||
if (type === "time") return miniTime();
|
||||
if (type === "volume" || type === "fx") return;
|
||||
renderMini();
|
||||
updateMini();
|
||||
if (type === "queue" || type === "track") {
|
||||
if (Mini.prefs.panel === "queue" || type === "track") Mini.lyricsFor = null;
|
||||
renderMiniPanel();
|
||||
}
|
||||
});
|
||||
window.addEventListener("resize", () => {
|
||||
if (!Mini.on) return;
|
||||
miniLayout();
|
||||
clearTimeout(Mini.sizeTimer);
|
||||
Mini.sizeTimer = setTimeout(async () => {
|
||||
const win = miniWin();
|
||||
if (win && (await win.isMaximized().catch(() => false))) await win.unmaximize().catch(() => {});
|
||||
try {
|
||||
localStorage.setItem("atmo.miniSize", JSON.stringify({ w: innerWidth, h: innerHeight }));
|
||||
} catch {}
|
||||
}, 300);
|
||||
});
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.target.closest("input, textarea, select, [contenteditable]") || e.altKey || e.ctrlKey || e.metaKey) return;
|
||||
|
||||
+65
-14
@@ -903,38 +903,44 @@ img { user-select: none; }
|
||||
|
||||
/* mini player */
|
||||
body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { display: none !important; }
|
||||
.mini { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--text); overflow: hidden; }
|
||||
.mini { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--text); overflow: hidden; --art: 0px; }
|
||||
.mini[hidden] { display: none; }
|
||||
.mini-bg { position: absolute; inset: -60px; background: var(--mini-art) center / cover no-repeat; filter: blur(46px) saturate(1.35) brightness(0.5); opacity: 0; transition: opacity 320ms var(--ease); pointer-events: none; z-index: 0; }
|
||||
.mini.with-blur .mini-bg { opacity: 1; }
|
||||
.mini > :not(.mini-bg) { position: relative; z-index: 1; }
|
||||
.mini.with-blur { color: #f4f5f8; --text-2: rgba(244, 245, 248, 0.74); --text-3: rgba(244, 245, 248, 0.52); --hover: rgba(255, 255, 255, 0.09); --hairline: rgba(255, 255, 255, 0.1); }
|
||||
.mini-top { flex: none; display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 6px 0 14px; }
|
||||
.mini.with-blur { color: #f4f5f8; --text: #f4f5f8; --text-2: rgba(244, 245, 248, 0.74); --text-3: rgba(244, 245, 248, 0.52); --hover: rgba(255, 255, 255, 0.09); --hairline: rgba(255, 255, 255, 0.1); }
|
||||
.mini-top { flex: none; display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 6px 0 14px; z-index: 3; transition: opacity 140ms var(--ease); }
|
||||
.mini-brand { font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: lowercase; color: var(--text-3); }
|
||||
.mini-opts { display: flex; gap: 2px; }
|
||||
.mini-opt[aria-pressed="true"] { color: var(--accent); }
|
||||
.mini.with-blur .mini-opt[aria-pressed="true"] { color: #fff; background: rgba(255, 255, 255, 0.12); }
|
||||
.mini-art { flex: none; display: grid; place-items: center; padding: 2px 20px 14px; }
|
||||
.mini-art img, .mini-art-empty { width: 100%; max-width: 268px; aspect-ratio: 1; border-radius: 12px; object-fit: cover; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.6); }
|
||||
|
||||
.mini-body { flex: none; display: flex; flex-direction: column; align-items: center; min-height: 0; }
|
||||
.mini-art { flex: none; width: var(--art); height: var(--art); margin: 2px auto 14px; }
|
||||
.mini.no-art .mini-art { display: none; }
|
||||
.mini-art img, .mini-art-empty { display: block; width: 100%; height: 100%; border-radius: 12px; object-fit: cover; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.6); }
|
||||
.mini-art-empty { display: grid; place-items: center; background: var(--surface); color: var(--text-3); }
|
||||
.mini-art-empty .i svg { width: 48px; height: 48px; }
|
||||
.mini-meta { flex: none; display: grid; gap: 2px; padding: 0 20px; text-align: center; min-width: 0; }
|
||||
.mini-art-empty .i svg { width: 40%; height: 40%; }
|
||||
.mini-info { width: 100%; min-width: 0; display: grid; gap: 10px; }
|
||||
.mini-meta { display: grid; gap: 2px; padding: 0 20px; text-align: center; min-width: 0; }
|
||||
.mini-title { font: 650 15px/1.3 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.mini-artist { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.mini-seek { flex: none; display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 8px; align-items: center; padding: 10px 14px 0; }
|
||||
.mini-seek { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 8px; align-items: center; padding: 0 14px; }
|
||||
.mini-t { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; text-align: center; }
|
||||
.mini-ctl { flex: none; display: flex; justify-content: center; align-items: center; gap: 22px; padding: 6px 0 12px; }
|
||||
.mini-ctl .icon-btn { width: 36px; height: 36px; color: var(--text-2); }
|
||||
.mini-ctl .icon-btn:hover { color: var(--text); }
|
||||
.mini-play { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); transition: transform 120ms var(--ease); }
|
||||
.mini-play { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); transition: transform 120ms var(--ease); flex: none; }
|
||||
.mini.with-blur .mini-play { background: #fff; color: #111318; }
|
||||
.mini-play:hover { transform: scale(1.05); }
|
||||
.mini-play:active { transform: scale(0.96); }
|
||||
.mini-play .i svg { width: 20px; height: 20px; }
|
||||
.mini-queue { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--hairline); }
|
||||
|
||||
.mini-panel { flex: 1; min-height: 0; display: none; flex-direction: column; border-top: 1px solid var(--hairline); }
|
||||
.mini.has-panel .mini-panel { display: flex; }
|
||||
.mq-head { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 4px 16px; font-size: 12px; font-weight: 600; color: var(--text-2); min-height: 34px; }
|
||||
.mq-list { flex: 1; overflow-y: auto; padding: 0 6px 8px; }
|
||||
.mq-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) 28px; gap: 6px; align-items: center; padding: 4px 4px 4px 4px; border-radius: 8px; cursor: grab; }
|
||||
.mq-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) 28px; gap: 6px; align-items: center; padding: 4px; border-radius: 8px; cursor: grab; }
|
||||
.mq-row:hover { background: var(--hover); }
|
||||
.mq-row .icon-btn { opacity: 0; }
|
||||
.mq-row:hover .icon-btn, .mq-row:focus-within .icon-btn { opacity: 1; }
|
||||
@@ -944,9 +950,50 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.mq-row.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
|
||||
.mq-row.drop-below { box-shadow: inset 0 -2px 0 var(--accent); }
|
||||
.mq-empty { margin: 0; padding: 6px 16px 12px; color: var(--text-3); font-size: 12.5px; }
|
||||
@media (prefers-reduced-motion: reduce) { .mini-bg, .mini-play { transition: none; } }
|
||||
.mini.mac .mini-top { padding-left: 78px; }
|
||||
.mini.mac .mini-brand { display: none; }
|
||||
.mini-lyr-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 80%, transparent); mask-image: linear-gradient(transparent, #000 14%, #000 80%, transparent); }
|
||||
.mini-lyr-scroll::-webkit-scrollbar { display: none; }
|
||||
.mini .lyr { gap: 6px; padding: 26px 18px 70%; }
|
||||
.mini .lyr.plain { padding: 14px 18px; }
|
||||
.mini .lyr-line { font-size: 15.5px; line-height: 1.35; }
|
||||
.mini .lyr.plain .lyr-line { font-size: 13.5px; }
|
||||
.mini .lyr-tr { font-size: 12px; }
|
||||
.mini-lyr-note { margin: auto; padding: 16px; color: var(--text-3); font-size: 12.5px; text-align: center; }
|
||||
|
||||
.mini.wide .mini-top, .mini.tiny .mini-top { position: absolute; top: 0; right: 0; height: 34px; padding: 0 4px; opacity: 0; }
|
||||
.mini.wide:hover .mini-top, .mini.tiny:hover .mini-top, .mini .mini-top:focus-within { opacity: 1; }
|
||||
.mini.wide .mini-brand, .mini.tiny .mini-brand { display: none; }
|
||||
.mini.wide .mini-opts .icon-btn, .mini.tiny .mini-opts .icon-btn { width: 26px; height: 26px; }
|
||||
.mini.wide .mini-body { flex: 1 1 auto; flex-direction: row; align-items: center; gap: 14px; padding: 12px 14px; }
|
||||
.mini.wide.has-panel .mini-body { flex: none; height: 112px; }
|
||||
.mini.wide .mini-art { margin: 0; }
|
||||
.mini.wide .mini-art img, .mini.wide .mini-art-empty { border-radius: 8px; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6); }
|
||||
.mini.wide .mini-info { flex: 1; gap: 8px; padding-top: 6px; }
|
||||
.mini.wide .mini-meta { text-align: left; padding: 0; }
|
||||
.mini.wide .mini-title { font-size: 14.5px; }
|
||||
.mini.wide .mini-seek { padding: 0; grid-template-columns: auto minmax(0, 1fr) auto; }
|
||||
.mini.wide .mini-t { min-width: 30px; }
|
||||
.mini.wide .mini-ctl { gap: 4px; padding: 6px 0 0; }
|
||||
.mini.wide .mini-ctl .icon-btn { width: 30px; height: 30px; }
|
||||
.mini.wide .mini-play { width: 38px; height: 38px; }
|
||||
.mini.wide .mini-play .i svg { width: 17px; height: 17px; }
|
||||
|
||||
.mini.tiny .mini-body { flex: 1 1 auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px 12px; }
|
||||
.mini.tiny .mini-info { flex: 1; gap: 0; }
|
||||
.mini.tiny .mini-meta { text-align: left; padding: 0; }
|
||||
.mini.tiny .mini-title { font-size: 13px; }
|
||||
.mini.tiny .mini-artist { font-size: 11.5px; }
|
||||
.mini.tiny .mini-seek { position: absolute; left: 0; right: 0; bottom: 0; padding: 0; display: block; }
|
||||
.mini.tiny .mini-seek .mini-t { display: none; }
|
||||
.mini.tiny .mini-seek .range { display: block; width: 100%; height: 4px; margin: 0; }
|
||||
.mini.tiny .mini-ctl { gap: 0; padding: 0; }
|
||||
.mini.tiny .mini-ctl .icon-btn { width: 28px; height: 28px; }
|
||||
.mini.tiny .mini-play { width: 32px; height: 32px; }
|
||||
.mini.tiny .mini-play .i svg { width: 15px; height: 15px; }
|
||||
|
||||
.mini.mac.portrait .mini-top { padding-left: 78px; }
|
||||
.mini.mac.portrait .mini-brand { display: none; }
|
||||
.mini.mac.wide .mini-body, .mini.mac.tiny .mini-body { padding-top: 30px; }
|
||||
@media (prefers-reduced-motion: reduce) { .mini-bg, .mini-play, .mini-top { transition: none; } }
|
||||
|
||||
/* linked playlist folders */
|
||||
.nav-item.missing { color: var(--text-3); }
|
||||
@@ -1014,3 +1061,7 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.side-tip { position: fixed; z-index: 120; transform: translate(-4px, -50%); opacity: 0; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 550; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; transition: opacity 100ms var(--ease), transform 100ms var(--ease); }
|
||||
.side-tip.on { opacity: 1; transform: translate(0, -50%); }
|
||||
@media (prefers-reduced-motion: reduce) { .shell, .titlebar, .side-tip { transition: none; } }
|
||||
|
||||
/* featured on */
|
||||
.tile-kind { font-weight: 600; color: var(--text-2); }
|
||||
.tile-sub.on { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
Reference in New Issue
Block a user