Web: queue button to the right, expandable art, big drag-anywhere stem faders
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e23311bff6
commit
115eb28bdf
3 files changed
+117
-25
No files matched your search
+84
-12
@@ -148,6 +148,21 @@ let drawer = null; // "mixer" | "lyrics" | "queue"
|
||||
const Lyr = { id: null, data: null, idx: -1 };
|
||||
const artOf = (t, size) => t?.srv ? img(t.srv, t.thumb, size) : "";
|
||||
|
||||
// Full-size album art over the content area, opened from the art in the player bar.
|
||||
const Big = {
|
||||
el: null,
|
||||
open() { if (!Q.cur() || Radio.station) return; this.el.hidden = false; this.fill(); },
|
||||
close() { if (this.el) this.el.hidden = true; },
|
||||
fill() {
|
||||
const o = this.el;
|
||||
if (!o || o.hidden) return;
|
||||
const t = Q.cur(), src = artOf(t, 1000);
|
||||
if (!src) return this.close();
|
||||
if (o.dataset.src !== src) { o.dataset.src = src; o.querySelector("img").src = src; o.querySelector(".bg").style.backgroundImage = `url("${src}")`; }
|
||||
o.querySelector(".t").textContent = t.title;
|
||||
o.querySelector(".s").textContent = [t.artist, t.album].filter(Boolean).join(" · ");
|
||||
},
|
||||
};
|
||||
const UI = {
|
||||
all() { this.track(); this.transport(); this.progress(); this.drawer(); marks(); },
|
||||
track() {
|
||||
@@ -158,6 +173,7 @@ const UI = {
|
||||
$("#np-title").textContent = st.name;
|
||||
$("#np-sub").textContent = "Web Radio";
|
||||
$("#np-art").removeAttribute("src");
|
||||
$("#b-art").hidden = true; Big.close();
|
||||
document.title = `${st.name} · Stemify`;
|
||||
if ("mediaSession" in navigator) navigator.mediaSession.metadata = new MediaMetadata({ title: st.name, artist: "Web Radio" });
|
||||
return;
|
||||
@@ -168,6 +184,7 @@ const UI = {
|
||||
$("#np-sub").textContent = t ? [t.artist, t.album].filter(Boolean).join(" · ") : "";
|
||||
const art = artOf(t, 120);
|
||||
if (art) $("#np-art").src = art; else $("#np-art").removeAttribute("src");
|
||||
$("#b-art").hidden = !art; Big.fill();
|
||||
document.title = t ? `${t.title} · Stemify` : "Stemify";
|
||||
if ("mediaSession" in navigator) {
|
||||
navigator.mediaSession.metadata = t ? new MediaMetadata({
|
||||
@@ -248,9 +265,8 @@ function mixerHtml() {
|
||||
${names.map(n => {
|
||||
const s = setting(n);
|
||||
return `<div class="stem ${stemGain(n, names) ? "" : "silent"} ${s.muted ? "muted" : ""}" data-stem="${esc(n)}" style="--c:${STEM_COLORS[n] || "#8e8e93"}">
|
||||
<span class="name"><i></i>${esc(n)}</span>
|
||||
<input type="range" min="0" max="1" step="0.01" value="${s.level}" data-level="${esc(n)}">
|
||||
<span class="pct">${pct(s.level)}</span>
|
||||
<div class="fader" data-fader="${esc(n)}" role="slider" tabindex="0" aria-label="${esc(n)} level" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${Math.round(s.level * 100)}" style="--v:${pct(s.level)}">
|
||||
<span class="name">${esc(n)}</span><span class="pct">${pct(s.level)}</span></div>
|
||||
<button class="ms mute ${s.muted ? "on" : ""}" data-mute="${esc(n)}" title="Mute">M</button>
|
||||
<button class="ms solo ${s.solo ? "on" : ""}" data-solo="${esc(n)}" title="Solo">S</button></div>`;
|
||||
}).join("")}
|
||||
@@ -264,18 +280,32 @@ function syncMixer() {
|
||||
const presetBox = box.querySelector(".presets"), html = presetsHtml(names);
|
||||
if (presetBox.innerHTML !== html) presetBox.innerHTML = html;
|
||||
for (const row of box.querySelectorAll(".stem")) {
|
||||
const n = row.dataset.stem, st = setting(n), r = row.querySelector("input");
|
||||
const n = row.dataset.stem, st = setting(n);
|
||||
row.classList.toggle("silent", !stemGain(n, names));
|
||||
row.classList.toggle("muted", !!st.muted);
|
||||
row.querySelector(".mute").classList.toggle("on", !!st.muted);
|
||||
row.querySelector(".solo").classList.toggle("on", !!st.solo);
|
||||
if (document.activeElement !== r) r.value = st.level;
|
||||
row.querySelector(".pct").textContent = pct(st.level);
|
||||
paintFader(row.querySelector(".fader"), st.level);
|
||||
}
|
||||
box.querySelector("#mixfoot").innerHTML = mixFoot(names);
|
||||
return true;
|
||||
}
|
||||
|
||||
const paintFader = (f, v) => {
|
||||
const p = pct(v);
|
||||
if (f.style.getPropertyValue("--v") === p) return;
|
||||
f.style.setProperty("--v", p); f.setAttribute("aria-valuenow", Math.round(v * 100)); f.querySelector(".pct").textContent = p;
|
||||
};
|
||||
// Sets a stem's level live; the save and mixer refresh wait until the gesture settles.
|
||||
let levelSave = 0;
|
||||
function setLevel(n, v) {
|
||||
v = Math.round(Math.max(0, Math.min(1, v)) * 100) / 100;
|
||||
if (setting(n).level === v) return;
|
||||
S.mix[n] = { ...setting(n), level: v }; E.applyGains(); Wave.draw();
|
||||
const f = $(`#mixer .fader[data-fader="${CSS.escape(n)}"]`); if (f) paintFader(f, v);
|
||||
clearTimeout(levelSave); levelSave = setTimeout(() => { save(); syncMixer(); }, 250);
|
||||
}
|
||||
|
||||
function queueHtml() {
|
||||
if (!Q.items.length) return `<p class="note">Empty.</p>`;
|
||||
const left = Q.items.length - Q.i - 1;
|
||||
@@ -332,16 +362,55 @@ d$.addEventListener("click", ev => {
|
||||
else if (ds.q) Q.jump(+ds.q);
|
||||
else if (ds.li) E.seek(Lyr.data.lines[+ds.li].t);
|
||||
});
|
||||
// Faders: a mouse sets the level where it presses and drags from there. A finger has to move
|
||||
// sideways first (or tap) so scrolling the drawer never changes a level.
|
||||
{
|
||||
let drag = null;
|
||||
const at = (f, x) => { const r = f.getBoundingClientRect(); setLevel(f.dataset.fader, (x - r.left) / r.width); };
|
||||
d$.addEventListener("pointerdown", ev => {
|
||||
const f = ev.target.closest(".fader");
|
||||
if (!f || ev.button) return;
|
||||
drag = { f, id: ev.pointerId, x0: ev.clientX, y0: ev.clientY, on: ev.pointerType === "mouse" };
|
||||
if (drag.on) { ev.preventDefault(); f.setPointerCapture(ev.pointerId); f.classList.add("drag"); at(f, ev.clientX); }
|
||||
});
|
||||
d$.addEventListener("pointermove", ev => {
|
||||
if (!drag || ev.pointerId !== drag.id) return;
|
||||
if (!drag.on) {
|
||||
const dx = Math.abs(ev.clientX - drag.x0), dy = Math.abs(ev.clientY - drag.y0);
|
||||
if (dy > 8 && dy > dx) { drag = null; return; }
|
||||
if (dx < 6) return;
|
||||
drag.on = true; drag.f.setPointerCapture(ev.pointerId); drag.f.classList.add("drag");
|
||||
}
|
||||
at(drag.f, ev.clientX);
|
||||
});
|
||||
const end = ev => {
|
||||
if (!drag || ev.pointerId !== drag.id) return;
|
||||
if (!drag.on && ev.type === "pointerup") at(drag.f, ev.clientX);
|
||||
drag.f.classList.remove("drag"); drag = null;
|
||||
};
|
||||
d$.addEventListener("pointerup", end);
|
||||
d$.addEventListener("pointercancel", end);
|
||||
d$.addEventListener("dblclick", ev => { const f = ev.target.closest(".fader"); if (f) setLevel(f.dataset.fader, 1); });
|
||||
d$.addEventListener("wheel", ev => {
|
||||
const f = ev.target.closest(".fader");
|
||||
if (!f) return;
|
||||
ev.preventDefault();
|
||||
setLevel(f.dataset.fader, setting(f.dataset.fader).level - Math.sign(ev.deltaY || -ev.deltaX) * 0.02);
|
||||
}, { passive: false });
|
||||
d$.addEventListener("keydown", ev => {
|
||||
const f = ev.target.closest(".fader");
|
||||
if (!f) return;
|
||||
const n = f.dataset.fader, v = setting(n).level, step = ev.shiftKey ? 0.1 : 0.02;
|
||||
const to = { ArrowRight: v + step, ArrowUp: v + step, ArrowLeft: v - step, ArrowDown: v - step, Home: 0, End: 1 }[ev.key];
|
||||
if (to == null) return;
|
||||
ev.preventDefault(); ev.stopPropagation(); setLevel(n, to);
|
||||
});
|
||||
}
|
||||
d$.addEventListener("input", ev => {
|
||||
const ds = ev.target.dataset;
|
||||
if (ds.level) {
|
||||
S.mix[ds.level] = { ...setting(ds.level), level: +ev.target.value }; E.applyGains(); Wave.draw();
|
||||
const p = ev.target.parentElement.querySelector(".pct"); if (p) p.textContent = pct(+ev.target.value);
|
||||
}
|
||||
if (ds.softdb) $("#softdb").textContent = ev.target.value + " dB";
|
||||
});
|
||||
d$.addEventListener("change", ev => {
|
||||
if (ev.target.dataset.level) { save(); syncMixer(); }
|
||||
if (ev.target.dataset.softdb) setKaraokeMode("soft", +ev.target.value);
|
||||
});
|
||||
// Long press (or right-click) a preset chip to lock it.
|
||||
@@ -408,6 +477,9 @@ function applyBar() {
|
||||
$("#speed").style.display = S.bar.speed ? "" : "none";
|
||||
for (const k of ["mixer", "lyrics", "queue"]) $(`#b-${k}`).style.display = S.bar[k] ? "" : "none";
|
||||
}
|
||||
Big.el = $("#bigart");
|
||||
Big.el.onclick = () => Big.close();
|
||||
$("#b-art").onclick = ev => { ev.stopPropagation(); Big.open(); };
|
||||
$(".np").onclick = () => { const t = Q.cur(); if (t?.albumKey) location.hash = `#/album/${t.srv}:${t.albumKey}`; };
|
||||
|
||||
if ("mediaSession" in navigator) {
|
||||
@@ -420,7 +492,7 @@ if ("mediaSession" in navigator) {
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", ev => {
|
||||
if (ev.key === "Escape") return Menu.close();
|
||||
if (ev.key === "Escape") { Big.close(); return Menu.close(); }
|
||||
if (ev.target.closest("input, select, textarea") || ev.metaKey || ev.ctrlKey || ev.altKey) return;
|
||||
const k = ev.key.toLowerCase();
|
||||
if (k === " ") { ev.preventDefault(); togglePlay(); }
|
||||
|
||||
+3
-2
@@ -32,9 +32,8 @@
|
||||
</div>
|
||||
<footer id="player" class="empty">
|
||||
<div class="left">
|
||||
<button id="b-queue" class="pill" title="Queue (Q)"></button>
|
||||
<div class="np">
|
||||
<img id="np-art" alt="">
|
||||
<button id="b-art" title="Expand art" hidden><img id="np-art" alt=""><span class="exp"><svg viewBox="0 0 24 24"><path d="M4 4h6v2H7.4l4 4-1.4 1.4-4-4V10H4V4zm16 0v6h-2V7.4l-4 4-1.4-1.4 4-4H14V4h6zM4 20v-6h2v2.6l4-4 1.4 1.4-4 4H10v2H4zm16 0h-6v-2h2.6l-4-4 1.4-1.4 4 4V14h2v6z"/></svg></span></button>
|
||||
<div class="np-text"><div id="np-title"></div><div id="np-sub"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,9 +55,11 @@
|
||||
<select id="speed" title="Speed ([ and ])"></select>
|
||||
<button id="b-mixer" class="pill" title="Mixer (M)"></button>
|
||||
<button id="b-lyrics" class="pill" title="Lyrics (L)"></button>
|
||||
<button id="b-queue" class="pill" title="Queue (Q)"></button>
|
||||
<input id="volume" type="range" min="0" max="1" step="0.01" title="Volume">
|
||||
</div>
|
||||
</footer>
|
||||
<div id="bigart" hidden><div class="bg"></div><button class="x" title="Close (Esc)">×</button><img alt=""><div class="cap"><div class="t"></div><div class="s"></div></div></div>
|
||||
<script type="module" src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+30
-11
@@ -210,14 +210,19 @@ input[type=color] { width: 40px; height: 28px; padding: 0; border: 1px solid var
|
||||
.chip { background: var(--raised); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; }
|
||||
.chip.on { background: var(--accent); color: var(--accent-ink); }
|
||||
.chip:disabled { opacity: .35; cursor: default; }
|
||||
.stem { --c: #8e8e93; display: grid; grid-template-columns: 96px 1fr 40px auto auto; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
|
||||
.stem .name { text-transform: capitalize; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.stem .name i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
|
||||
.stem input { width: 100%; accent-color: var(--c); }
|
||||
.stem .pct { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.stem.silent .name, .stem.silent .pct { color: var(--muted); }
|
||||
.stem.silent .name i, .stem.silent input { opacity: .35; }
|
||||
.ms { width: 32px; height: 30px; border-radius: 8px; background: var(--raised); font-size: 12px; font-weight: 800; color: var(--muted);
|
||||
.stem { --c: #8e8e93; display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: stretch; margin-bottom: 8px; }
|
||||
.fader { position: relative; height: 54px; border-radius: 10px; overflow: hidden; cursor: ew-resize; touch-action: pan-y; user-select: none; -webkit-user-select: none;
|
||||
background: color-mix(in srgb, var(--c) 12%, var(--raised)); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; outline: none; }
|
||||
.fader::before { content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--v)); will-change: transform;
|
||||
background: linear-gradient(90deg, color-mix(in srgb, var(--c) 45%, transparent), color-mix(in srgb, var(--c) 75%, transparent)); pointer-events: none; }
|
||||
.fader::after { content: ""; position: absolute; top: 8px; bottom: 8px; left: clamp(2px, calc(var(--v) - 3px), calc(100% - 5px)); width: 3px; border-radius: 2px; background: var(--c); box-shadow: 0 0 8px var(--c); pointer-events: none; }
|
||||
.fader:focus-visible { box-shadow: 0 0 0 2px var(--c); }
|
||||
.fader.drag::after { width: 4px; }
|
||||
.fader .name, .fader .pct { position: relative; z-index: 1; pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .55); }
|
||||
.fader .name { text-transform: capitalize; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.fader .pct { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
||||
.stem.silent .fader { filter: saturate(.15); opacity: .55; }
|
||||
.ms { width: 44px; height: auto; border-radius: 8px; background: var(--raised); font-size: 12px; font-weight: 800; color: var(--muted);
|
||||
transition: transform .08s, background-color .12s, color .12s; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
|
||||
.ms:active { transform: scale(.88); }
|
||||
.ms.mute.on { background: #ff453a; color: #fff; }
|
||||
@@ -238,9 +243,24 @@ input[type=color] { width: 40px; height: 28px; padding: 0; border: 1px solid var
|
||||
|
||||
#player { position: fixed; left: 0; right: 0; bottom: 0; height: var(--player-h); background: var(--bg);
|
||||
border-top: 1px solid rgba(50, 50, 50, .7); display: grid; grid-template-columns: minmax(180px, 1fr) minmax(320px, 1.6fr) minmax(180px, 1fr); align-items: center; gap: 20px; padding: 0 20px; }
|
||||
#player.empty .center, #player.empty .right, #player.empty #b-queue { opacity: .35; pointer-events: none; }
|
||||
#player.empty .center, #player.empty .right, #player.empty #b-art { opacity: .35; pointer-events: none; }
|
||||
.left { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
||||
#b-queue { flex: none; }
|
||||
#b-art { position: relative; flex: none; width: 60px; height: 60px; padding: 0; border-radius: 4px; overflow: hidden; cursor: zoom-in; }
|
||||
#b-art[hidden] { display: none; }
|
||||
#b-art .exp { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .5); opacity: 0; transition: opacity .15s; }
|
||||
#b-art .exp svg { width: 22px; height: 22px; fill: #fff; }
|
||||
#b-art:hover .exp, #b-art:focus-visible .exp { opacity: 1; }
|
||||
#bigart { position: fixed; inset: 0 0 var(--player-h) 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
|
||||
padding: 32px 16px; background: #000; overflow: hidden; cursor: zoom-out; animation: bigin .18s ease-out; }
|
||||
#bigart[hidden] { display: none; }
|
||||
#bigart .bg { position: absolute; inset: -80px; background-size: cover; background-position: center; filter: blur(70px) brightness(.4) saturate(1.3); transform: translateZ(0); }
|
||||
#bigart img { position: relative; width: min(68vh, 88vw, 760px); aspect-ratio: 1; object-fit: cover; border-radius: 8px; box-shadow: 0 24px 70px rgba(0, 0, 0, .65); }
|
||||
#bigart .cap { position: relative; text-align: center; max-width: 88vw; }
|
||||
#bigart .t { font-size: clamp(20px, 3vw, 30px); font-weight: 800; }
|
||||
#bigart .s { color: rgba(255, 255, 255, .7); margin-top: 4px; }
|
||||
#bigart .x { position: absolute; top: 14px; right: 18px; font-size: 28px; color: #fff; opacity: .7; }
|
||||
#bigart .x:hover { opacity: 1; }
|
||||
@keyframes bigin { from { opacity: 0; } }
|
||||
.np { display: flex; gap: 12px; align-items: center; min-width: 0; }
|
||||
#np-art { width: 60px; height: 60px; border-radius: 4px; object-fit: cover; background: var(--raised); flex: none; }
|
||||
#np-art:not([src]) { display: none; }
|
||||
@@ -295,7 +315,6 @@ input[type=range] { accent-color: var(--accent); }
|
||||
#player { grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 8px 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
|
||||
.center { grid-column: 1 / -1; grid-row: 2; }
|
||||
.right #volume { display: none; }
|
||||
.stem { grid-template-columns: 78px 1fr 36px auto auto; gap: 6px; }
|
||||
.hero { margin: -20px -16px 0; padding: 32px 16px 20px; }
|
||||
.hero-in { flex-direction: column; align-items: flex-start; gap: 18px; }
|
||||
.hero .art, .hero .ph { width: 160px; height: 160px; }
|
||||
|
||||
Reference in new issue
Block a user