diff --git a/android/app/src/main/assets/pulsewall/preset-music.html b/android/app/src/main/assets/pulsewall/preset-music.html
index 4ca09c5..c03cfea 100644
--- a/android/app/src/main/assets/pulsewall/preset-music.html
+++ b/android/app/src/main/assets/pulsewall/preset-music.html
@@ -211,75 +211,103 @@ body {
background: linear-gradient(90deg, #4ade80, #38bdf8);
transition: width .9s linear;
}
-/* ---- 音量 ---- */
-#vol-block {
- width: 100%;
+/* ---- 音量:图标按钮 + 竖向浮层面板 ---- */
+/* 尺寸与三档循环一致(5.4vh),并用绝对定位钉在最左侧,
+ 不参与主控三键的居中计算,避免影响它们的样式与间距。 */
+.ctrl-btn.ctrl-vol {
+ position: absolute;
+ left: 0;
+ bottom: 0; /* 与右侧三档键一致的底部对齐 */
+ top: auto;
+ transform: none;
+ width: 5.4vh;
+ height: 5.4vh;
+ font-size: 2.2vh;
+}
+.ctrl-btn.ctrl-vol.active {
+ color: var(--accent);
+ border-color: var(--line-hard);
+ background: rgba(76, 201, 240, .14);
+}
+
+#vol-pop {
+ position: absolute;
+ left: 1.6vw;
+ bottom: 11vh;
+ z-index: 20;
+ width: 6.4vh;
+ padding: 1vh 0;
display: flex;
flex-direction: column;
- gap: 0.6vh;
- flex: 0 0 auto;
+ align-items: center;
+ gap: 0.8vh;
+ border-radius: var(--radius-md);
+ background: rgba(17, 28, 51, .97);
+ border: 1px solid var(--line-mid);
+ box-shadow: 0 1vh 3vh rgba(0, 0, 0, .55);
+ opacity: 0;
+ visibility: hidden;
+ transform: translateY(0.6vh);
+ transition: opacity .16s ease, transform .16s ease, visibility .16s;
}
-#vol-head {
- display: flex;
- justify-content: space-between;
- font-size: 1.3vh; color: #7d8fb0;
+#vol-pop.show {
+ opacity: 1;
+ visibility: visible;
+ transform: translateY(0);
}
-#vol-head .val { font-weight: 700; color: #a9bcda; }
-#vol-bar {
+#vol-pop-val {
+ font-size: 1.5vh;
+ font-weight: 700;
+ color: var(--accent);
+ font-variant-numeric: tabular-nums;
+ line-height: 1;
+}
+
+#vol-track {
position: relative;
- height: 1.5vh; /* 2.4 -> 1.5,缩小 */
+ width: 1.5vh;
+ height: 18vh;
border-radius: 99vh;
- background: rgba(148,163,184,.17);
+ background: rgba(120, 160, 220, .16);
+ outline: none;
cursor: pointer;
touch-action: none;
- /* 关键:不加 outline:none 时,遥控器聚焦会出现浏览器默认的
- 黄色/橙色焦点环,与深蓝主题极度违和 */
- outline: none;
- border: 1px solid transparent;
- transition: border-color .15s, background .15s;
}
-/* WebView 旧版还会画默认 focus-visible 环,显式压掉 */
-#vol-bar:focus,
-#vol-bar:focus-visible {
+#vol-track:focus,
+#vol-track:focus-visible {
outline: none;
box-shadow: none;
}
-#vol-fill {
- position: absolute; top: 0; bottom: 0; left: 0;
- width: 0%;
- border-radius: 99vh;
- background: linear-gradient(90deg, #3ec4f8, #818cf8);
- pointer-events: none;
-}
-#vol-knob {
- position: absolute;
- top: 50%;
- left: 0%;
- width: 2.9vh; height: 2.9vh;
- margin-left: -1.45vh;
- margin-top: -1.45vh;
- border-radius: 50%;
- background: #eaf6ff;
- border: 0.25vh solid #3ec4f8;
- box-shadow: 0 0.3vh 1vh rgba(0,0,0,.55);
- pointer-events: none;
- transition: transform .1s ease;
-}
-#vol-bar.dragging #vol-knob { transform: scale(1.18); }
-/* 遥控器调节态:整条高亮 + 手柄放大常亮 */
-#vol-bar.adjusting {
- background: rgba(62,196,248,.28);
- box-shadow: 0 0 0 0.25vh rgba(62,196,248,.55), 0 0 2vh rgba(62,196,248,.28);
+/* 竖向填充:从底部往上 */
+#vol-track-fill {
+ position: absolute;
+ left: 0; right: 0; bottom: 0;
+ height: 15%;
+ border-radius: 99vh;
+ background: linear-gradient(0deg, #4cc9f0, #6a8dff);
+ pointer-events: none;
+ transition: height .12s linear;
}
-#vol-bar.adjusting #vol-knob {
- transform: scale(1.22);
- background: #ffffff;
- box-shadow: 0 0 1.4vh rgba(62,196,248,.9);
+#vol-track-knob {
+ position: absolute;
+ left: 50%;
+ bottom: 15%;
+ width: 2.4vh; height: 2.4vh;
+ margin-left: -1.2vh;
+ margin-bottom: -1.2vh;
+ border-radius: 50%;
+ background: #fff;
+ border: 0.25vh solid var(--accent);
+ box-shadow: 0 0.3vh 1vh rgba(0, 0, 0, .6);
+ pointer-events: none;
+ transition: bottom .12s linear;
+}
+#vol-track.adjusting #vol-track-knob {
+ transform: scale(1.15);
+ box-shadow: 0 0 1.4vh rgba(76, 201, 240, .9);
}
-/* 音量数值在调节态发光 */
-#vol-block.adj #vol-label { color: #7dd3fc; text-shadow: 0 0 1vh rgba(62,196,248,.8); }
flex: 1 1 0;
padding: 0.65vh 0.3vw;
@@ -309,6 +337,11 @@ body {
justify-content: center;
gap: 1.2vh;
width: 100%;
+ /* 左右各有一个绝对定位按钮(音量 / 播放方式),
+ 留出等量内边距,保证中间三键仍相对整行居中 */
+ padding-left: 6.2vh;
+ padding-right: 6.2vh;
+ box-sizing: border-box;
}
/* 播放方式按钮:绝对定位挂在右侧,不参与主组的居中计算,
@@ -627,25 +660,29 @@ body {
-
@@ -725,7 +762,8 @@ body {
// 切歌冻结:从点击到服务端确认之间,禁止 syncPlayerStatus 覆盖本地 source,
// 否则会出现「高亮切过去 → 被旧状态拉回 → 再跳回」的三段闪烁
pendingSource: null,
- pendingUntil: 0
+ pendingUntil: 0,
+ volPanelOpen: false
};
/* ============ 日志 / 状态 ============ */
@@ -1246,17 +1284,60 @@ body {
/* ============ 渲染 ============ */
function renderVolume() {
- var pct = (state.volume / VOL_MAX) * 100;
- var f = $("vol-fill");
- if (f) f.style.width = Math.max(0, Math.min(100, pct)) + "%";
- var k = $("vol-knob");
- if (k) k.style.left = Math.max(0, Math.min(100, pct)) + "%";
- var l = $("vol-label");
- if (l) l.textContent = state.volume + " / " + VOL_MAX;
- var kb = $("vol-knob");
- if (kb) FX.volumePulse(kb);
- var bar = $("vol-bar");
- if (bar) bar.setAttribute("aria-valuenow", String(state.volume));
+ var pct = Math.max(0, Math.min(100, (state.volume / VOL_MAX) * 100));
+
+ // 竖向面板:填充从底部往上长,手柄跟着走
+ var f = $("vol-track-fill");
+ if (f) f.style.height = pct + "%";
+ var k = $("vol-track-knob");
+ if (k) {
+ k.style.bottom = pct + "%";
+ FX.volumePulse(k);
+ }
+
+ // 数值
+ var v = $("vol-pop-val");
+ if (v) v.textContent = String(state.volume);
+
+ var t = $("vol-track");
+ if (t) t.setAttribute("aria-valuenow", String(state.volume));
+ }
+
+ /* ---- 音量面板开关 ---- */
+ function openVolPanel() {
+ var pop = $("vol-pop");
+ var btn = $("btn-vol");
+ if (!pop) return;
+ pop.classList.add("show");
+ pop.setAttribute("aria-hidden", "false");
+ if (btn) btn.classList.add("active");
+ state.volPanelOpen = true;
+ state.volAdjusting = true;
+ syncVolMode();
+ // 焦点移到竖向滑轨,方便直接按上下键
+ var trk = $("vol-track");
+ if (trk) {
+ collect();
+ focIdx = foc.indexOf(trk);
+ if (focIdx >= 0) setFocus(trk);
+ trk.classList.add("adjusting");
+ }
+ log("音量 " + state.volume + ":↑↓ 调节,OK 收起", "");
+ }
+
+ function closeVolPanel() {
+ var pop = $("vol-pop");
+ var btn = $("btn-vol");
+ if (!pop) return;
+ pop.classList.remove("show");
+ pop.setAttribute("aria-hidden", "true");
+ if (btn) btn.classList.remove("active");
+ state.volPanelOpen = false;
+ state.volAdjusting = false;
+ syncVolMode();
+ var trk = $("vol-track");
+ if (trk) trk.classList.remove("adjusting");
+ log("音量 " + state.volume, "ok");
}
function fmtDur(sec) {
@@ -1447,7 +1528,7 @@ body {
function collect() {
// 注意:.btn 是旧样式,新控制按钮用 .ctrl-btn / .icon-btn,必须一并纳入,
// 否则遥控器方向键无法把焦点移动到上一首/下一首/播放方式等按钮。
- var nodes = document.querySelectorAll(".track, .btn, .ctrl-btn, .icon-btn, #vol-bar");
+ var nodes = document.querySelectorAll(".track, .btn, .ctrl-btn, .icon-btn");
foc = Array.prototype.slice.call(nodes).filter(function (el) {
if (el.disabled) return false;
var r = el.getBoundingClientRect();
@@ -1513,46 +1594,43 @@ body {
window.__pwRemoteKey = function (dir) {
collect();
- var volBar = $("vol-bar");
+ var volTrk = $("vol-track");
+ var volBtn = $("btn-vol");
- // ---- 音量条特处理:聚焦后按 OK 进入调节态,左右键 ±VOL_STEP ----
- if (volBar) {
- var volFocused = (foc[focIdx] === volBar);
-
- if (dir === "ok") {
- if (volFocused) {
- // 已在音量条上:切换「调节态」
- state.volAdjusting = !state.volAdjusting;
- syncVolMode();
- if (state.volAdjusting) log("音量调节模式:← -" + VOL_STEP + " → +" + VOL_STEP, "");
- return true;
- }
- var cur = foc[focIdx];
- if (!cur) { focusFirst(); return true; }
- cur.click();
- return true;
- }
-
- if (volFocused && state.volAdjusting && (dir === "left" || dir === "right")) {
- var delta = (dir === "right" ? VOL_STEP : -VOL_STEP);
+ // ============ 音量面板已展开:上下键调音量,OK 收起 ============
+ if (state.volPanelOpen) {
+ if (dir === "up" || dir === "down") {
+ var delta = (dir === "up" ? VOL_STEP : -VOL_STEP);
setVolume(state.volume + delta);
return true;
}
+ if (dir === "ok") {
+ closeVolPanel();
+ return true;
+ }
+ // 其他方向键:先收起面板再交给常规导航
+ closeVolPanel();
+ return true;
}
- // 离开音量条时退出调节态
- if (state.volAdjusting && dir !== "ok" && (!volBar || foc[focIdx] !== volBar)) {
- state.volAdjusting = false;
- syncVolMode();
+ // ============ OK 键 ============
+ if (dir === "ok") {
+ var cur = foc[focIdx];
+ if (!cur) { focusFirst(); return true; }
+ // 焦点在音量图标上 -> 展开面板(不触发 click,避免又开又关)
+ if (cur === volBtn) {
+ openVolPanel();
+ return true;
+ }
+ cur.click();
+ return true;
}
+ // ============ 方向键导航 ============
var next = nextInDir(dir);
if (next) {
setFocus(next);
focIdx = foc.indexOf(next);
- // 焦点进入音量条时自动进入调节态,省一步
- state.volAdjusting = (next === volBar);
- syncVolMode();
return true;
}
@@ -1564,14 +1642,12 @@ body {
return false;
};
- /* 音量条调节态的视觉反馈 */
+ /* 音量调节态的视觉反馈 */
function syncVolMode() {
- var bar = $("vol-bar");
- if (!bar) return;
- if (state.volAdjusting) bar.classList.add("adjusting");
- else bar.classList.remove("adjusting");
- var blk = $("vol-block");
- if (blk) { if (state.volAdjusting) blk.classList.add("adj"); else blk.classList.remove("adj"); }
+ var trk = $("vol-track");
+ if (!trk) return;
+ if (state.volAdjusting) trk.classList.add("adjusting");
+ else trk.classList.remove("adjusting");
}
window.__pwFocusFirst = focusFirst;
@@ -1588,90 +1664,6 @@ body {
if (!isNaN(idx) && state.tracks[idx]) playTrack(state.tracks[idx]);
});
- /* ---- 音量滑块:点击 + 拖拽(触摸/鼠标) ---- */
- var volBar = $("vol-bar");
- if (volBar) {
- var dragging = false;
- var lastSent = -1;
-
- function volFromX(clientX) {
- var r = volBar.getBoundingClientRect();
- var pct = (clientX - r.left) / r.width;
- pct = Math.min(1, Math.max(0, pct));
- return Math.round(pct * VOL_MAX);
- }
-
- function beginDrag(e) {
- dragging = true;
- volBar.classList.add("dragging");
- var v = volFromX(e.clientX);
- state.volume = v;
- renderVolume();
- lastSent = v;
- }
-
- function moveDrag(e) {
- if (!dragging) return;
- var v = volFromX(e.clientX);
- if (v === state.volume) return;
- state.volume = v;
- renderVolume();
- // 拖拽中限制发送频率(每 8 个单位发一次),松手时再补一次精确值
- if (Math.abs(v - lastSent) >= 8) {
- lastSent = v;
- setVolume(v, true);
- }
- }
-
- function endDrag(e) {
- if (!dragging) return;
- dragging = false;
- volBar.classList.remove("dragging");
- try { volBar.focus({ preventScroll: true }); } catch (_) {}
- collect(); focIdx = foc.indexOf(volBar);
- var v = e && typeof e.clientX === "number" ? volFromX(e.clientX) : state.volume;
- setVolume(v); // 最终值一定发送
- }
-
- volBar.addEventListener("pointerdown", function (e) {
- e.preventDefault();
- // 触摸即视为进入调节态,之后可直接用遥控器左右键微调
- state.volAdjusting = true;
- syncVolMode();
- try { volBar.setPointerCapture(e.pointerId); } catch (_) {}
- beginDrag(e);
- });
- volBar.addEventListener("pointermove", moveDrag);
- volBar.addEventListener("pointerup", endDrag);
- volBar.addEventListener("pointercancel", endDrag);
-
- // 鼠标兼容(Android WebView 84 可能不支持 pointer 事件)
- volBar.addEventListener("mousedown", function (e) {
- if (dragging) return;
- e.preventDefault();
- state.volAdjusting = true;
- syncVolMode();
- beginDrag(e);
- var up = function (ev) {
- document.removeEventListener("mousemove", moveDrag);
- document.removeEventListener("mouseup", up);
- endDrag(ev);
- };
- document.addEventListener("mousemove", moveDrag);
- document.addEventListener("mouseup", up);
- });
-
- // 键盘/遥控器左右键微调音量
- volBar.addEventListener("keydown", function (e) {
- var step = e.shiftKey ? 1 : 5;
- if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
- e.preventDefault(); setVolume(state.volume - step);
- } else if (e.key === "ArrowRight" || e.key === "ArrowUp") {
- e.preventDefault(); setVolume(state.volume + step);
- }
- });
- }
-
$("btn-refresh").addEventListener("click", function () {
var ic = this;
ic.classList.remove("spinning");
@@ -1700,6 +1692,76 @@ body {
});
}
+ // 音量图标:点击展开面板(遥控器走 __pwRemoteKey 分支)
+ var volBtn = $("btn-vol");
+ if (volBtn) {
+ volBtn.addEventListener("click", function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ FX.press(volBtn);
+ if (state.volPanelOpen) closeVolPanel();
+ else openVolPanel();
+ });
+ }
+
+ // 竖向滑轨:支持触摸/鼠标点按与拖动
+ var volTrk = $("vol-track");
+ if (volTrk) {
+ var vDragging = false;
+
+ function volFromY(clientY) {
+ var r = volTrk.getBoundingClientRect();
+ // 从下往上:底部=0%,顶部=100%
+ var pct = (r.bottom - clientY) / r.height;
+ pct = Math.min(1, Math.max(0, pct));
+ return Math.round(pct * VOL_MAX);
+ }
+
+ function vBegin(e) {
+ vDragging = true;
+ state.volAdjusting = true;
+ syncVolMode();
+ var v = volFromY(e.clientY);
+ state.volume = v;
+ renderVolume();
+ }
+ function vMove(e) {
+ if (!vDragging) return;
+ var v = volFromY(e.clientY);
+ if (v === state.volume) return;
+ state.volume = v;
+ renderVolume();
+ }
+ function vEnd(e) {
+ if (!vDragging) return;
+ vDragging = false;
+ var v = (e && typeof e.clientY === "number") ? volFromY(e.clientY) : state.volume;
+ setVolume(v);
+ }
+
+ volTrk.addEventListener("pointerdown", function (e) {
+ e.preventDefault();
+ try { volTrk.setPointerCapture(e.pointerId); } catch (_) {}
+ vBegin(e);
+ });
+ volTrk.addEventListener("pointermove", vMove);
+ volTrk.addEventListener("pointerup", vEnd);
+ volTrk.addEventListener("pointercancel", vEnd);
+
+ volTrk.addEventListener("mousedown", function (e) {
+ if (vDragging) return;
+ e.preventDefault();
+ vBegin(e);
+ var up = function (ev) {
+ document.removeEventListener("mousemove", vMove);
+ document.removeEventListener("mouseup", up);
+ vEnd(ev);
+ };
+ document.addEventListener("mousemove", vMove);
+ document.addEventListener("mouseup", up);
+ });
+ }
+
wire("btn-toggle", togglePlay);
wire("btn-prev", playPrev);
wire("btn-next", playNext);