Refine MPC elapsed and playback state labels

This commit is contained in:
Dandaedre 2026-11-12 07:58:01 +01:00
parent 9ce5686c40
commit eb3d3c8b6b
3 changed files with 10 additions and 2 deletions

View File

@ -103,6 +103,9 @@ would not preload it in MPC-HC and is not implemented here.
## Variables and custom feedback
The elapsed preset uses the compact label **ELAP.** to avoid wrapping. The
playback-state preset displays **Playing**, **Paused**, **Stopped**, or **Idle**.
These are connection/module variables, not button-local variables. With the
connection labelled `MPC_DEV`, use `$(MPC_DEV:remaining)` in button text.
Presets are wired automatically to the connection label.
@ -116,6 +119,9 @@ Presets are wired automatically to the connection label.
| `elapsed_seconds`, `duration_seconds`, `remaining_seconds` | Numeric media seconds; null when unknown |
| `progress` | Percentage from 0 to 100; null when duration is unknown |
`state_label` provides capitalized display text; `state` retains lowercase values
for expressions and existing buttons.
Mute is separate from volume zero: `muted` follows MPC's mute switch.
For existing/custom buttons, add **Playing**, **Stopped**, **Paused**, **Audio
muted**, **No active media (idle)**, **Status unavailable**, or **Playback progress

View File

@ -59,10 +59,10 @@ export function presets(label = 'MPC_DEV') {
transport_remaining: button('Remaining time and progress', `LEFT\n$(${label}:remaining)`, null, [
{ feedbackId: 'progress_bar', options: {} },
]),
transport_elapsed: button('Elapsed time and progress', `ELAPSED\n$(${label}:elapsed)`, null, [
transport_elapsed: button('Elapsed time and progress', `ELAP.\n$(${label}:elapsed)`, null, [
{ feedbackId: 'progress_bar', options: {} },
]),
transport_state: button('Playback state', `$(${label}:state)`, null, [
transport_state: button('Playback state', `$(${label}:state_label)`, null, [
active('playing', colors.green),
active('paused', colors.amber),
active('stopped', colors.red),

View File

@ -65,6 +65,7 @@ export const variableDefinitions = Object.fromEntries(
Object.entries({
connected: 'Status data is available',
state: 'Playback state: playing, paused, stopped, idle, or offline',
state_label: 'Playback state for display: Playing, Paused, Stopped, Idle, or Offline',
playing: 'Player reports playing',
stopped: 'Player reports stopped (idle is separate)',
paused: 'Player reports paused',
@ -87,6 +88,7 @@ export function variables(state) {
return {
connected: !!state,
state: state?.state ?? 'offline',
state_label: state ? state.state[0].toUpperCase() + state.state.slice(1) : 'Offline',
playing: state ? state.state === 'playing' : null,
stopped: state ? state.state === 'stopped' : null,
paused: state ? state.state === 'paused' : null,