Use subtle transport borders instead of filled backgrounds
This commit is contained in:
parent
4a5c09dbe3
commit
dd59463247
|
|
@ -46,16 +46,16 @@ their selected version until you explicitly change them.
|
|||
Open **Presets → MPC_DEV → Transport & timing** and drag the buttons onto a
|
||||
spare page. These presets already include their feedback and variable references:
|
||||
|
||||
| Preset | Behavior |
|
||||
| --------------------- | -------------------------------------------------------------------------- |
|
||||
| ▶ Play | Dark green while waiting; brighter green while playing, amber while paused |
|
||||
| ■ Stop | Stop command; red while the player reports stopped |
|
||||
| ◀◀ Previous / ▶▶ Next | Previous/next **playlist item**, not chapter or seek |
|
||||
| Mute | Toggle mute; red **MUTED** when the player mute switch is on |
|
||||
| Pause | Pause command; amber while paused |
|
||||
| Remaining | Live media countdown and progress bar |
|
||||
| Elapsed | Live elapsed media time and progress bar |
|
||||
| Playback state | Playing, paused, stopped, idle, or offline with matching colors |
|
||||
| Preset | Behavior |
|
||||
| --------------------- | --------------------------------------------------------------- |
|
||||
| ▶ Play | Thin green outline; thicker while playing, amber while paused |
|
||||
| ■ Stop | Stop command; thicker red outline while stopped |
|
||||
| ◀◀ Previous / ▶▶ Next | Previous/next **playlist item**, not chapter or seek |
|
||||
| Mute | Toggle mute; thicker red outline and **MUTED** while muted |
|
||||
| Pause | Pause command; thicker amber outline while paused |
|
||||
| Remaining | Live media countdown and progress bar |
|
||||
| Elapsed | Live elapsed media time and progress bar |
|
||||
| Playback state | Playing, paused, stopped, idle, or offline with matching colors |
|
||||
|
||||
The Previous/Next transport presets use command IDs verified against this
|
||||
player's `/commands.json`: Previous → `919`, Next → `920`. The old catalog was
|
||||
|
|
@ -64,10 +64,12 @@ Navigation-related labels are corrected; numeric action IDs still send their
|
|||
same numeric commands. Re-add copied presets to existing buttons to apply
|
||||
this correction; linked presets follow the module update.
|
||||
|
||||
Transport buttons use white icons/text on colored backgrounds: green Play,
|
||||
burgundy Stop, ochre Pause, blue Previous/Next, and purple Mute. Timing displays
|
||||
use teal. Active states brighten the background; paused feedback uses dark text
|
||||
on amber for contrast, and mute changes to red **MUTED**. Offline remains grey.
|
||||
Transport buttons use white icons/text on dark backgrounds with thin colored
|
||||
outlines: green Play, red Stop, amber Pause, blue Previous/Next, and purple Mute.
|
||||
Active controls have thicker outlines; paused Play turns amber and muted audio
|
||||
turns red with **MUTED** text. Offline outlines turn grey. Timing displays stay
|
||||
dark with their progress bars. Backup sync retains its dedicated status colors.
|
||||
Re-add copied presets to apply styling updates; linked presets update automatically.
|
||||
|
||||
The progress bar fills from left to right. It turns amber with 10 seconds left
|
||||
and red with 5 seconds left. Timing displays are passive: pressing them does
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ in this connection. Allow remote access from the Companion computer if needed.
|
|||
|
||||
Choose **Transport & timing** in this connection's Presets:
|
||||
|
||||
- **Play**: white text on dark green while waiting; brighter green while playing; amber while paused. Press to play/resume.
|
||||
- **Stop**: red while stopped.
|
||||
- **Play**: thin green outline while waiting; thicker while playing; amber while paused. Press to play/resume.
|
||||
- **Stop**: thicker red outline while stopped.
|
||||
- **Previous / Next**: navigate playlist items (verified command IDs 919/920).
|
||||
These load and start playback; the web API has no reliable open-next-paused
|
||||
command. A Next-then-Stop sequence can briefly play and is not offered as cueing.
|
||||
|
|
@ -22,9 +22,12 @@ The bar fills left to right, turning amber with 10 media seconds left and red
|
|||
with 5 seconds left. All 138 original command presets remain in **All commands**.
|
||||
Open File opens a dialog on the player computer; it does not upload a file.
|
||||
|
||||
Transport backgrounds identify controls: green Play, burgundy Stop, ochre Pause,
|
||||
blue Previous/Next, purple Mute, and teal timing displays. Active feedback uses
|
||||
brighter backgrounds; paused feedback uses dark text on amber for contrast.
|
||||
Transport buttons use dark backgrounds and white labels with thin colored
|
||||
outlines: green Play, red Stop, amber Pause, blue Previous/Next, and purple Mute.
|
||||
Active controls have thicker outlines; mute turns red with **MUTED** text.
|
||||
Offline outlines turn grey. Timers keep their progress bars on dark backgrounds.
|
||||
Backup sync keeps its dedicated status colors. Re-add copied presets for the new
|
||||
style; linked presets update automatically.
|
||||
|
||||
## Optional backup
|
||||
|
||||
|
|
|
|||
|
|
@ -46,17 +46,17 @@ export function presets(label = 'MPC_DEV') {
|
|||
options: {},
|
||||
style: { text: 'OFFLINE', bgcolor: colors.dark, color: 0x889099 },
|
||||
}
|
||||
const active = (feedbackId, bgcolor, text) => ({
|
||||
const active = (feedbackId, text) => ({
|
||||
feedbackId,
|
||||
options: {},
|
||||
style: { bgcolor, color: bgcolor === colors.amber ? colors.dark : colors.white, ...(text ? { text } : {}) },
|
||||
style: { ...(text ? { text } : {}) },
|
||||
})
|
||||
const button = (name, text, id, feedback = [], size = '18', bgcolor = colors.dark) => ({
|
||||
const button = (name, text, id, feedback = [], size = '18', control = null) => ({
|
||||
type: 'simple',
|
||||
name,
|
||||
style: { text, size, color: colors.white, bgcolor, show_topbar: false },
|
||||
style: { text, size, color: colors.white, bgcolor: colors.dark, show_topbar: false },
|
||||
steps: [{ down: id ? [{ actionId: id, options: { target: 'both' } }] : [], up: [] }],
|
||||
feedbacks: [...feedback, offline],
|
||||
feedbacks: [...feedback, ...(control ? [{ feedbackId: 'transport_border', options: { control } }] : []), offline],
|
||||
})
|
||||
const transport = {
|
||||
transport_redundancy: {
|
||||
|
|
@ -70,44 +70,22 @@ export function presets(label = 'MPC_DEV') {
|
|||
'Play — green while playing',
|
||||
'▶\nPLAY',
|
||||
'887',
|
||||
[active('playing', colors.green), active('paused', colors.amber, 'Ⅱ\nPAUSED')],
|
||||
[active('paused', 'Ⅱ\nPAUSED')],
|
||||
'18',
|
||||
0x14532d,
|
||||
),
|
||||
transport_stop: button(
|
||||
'Stop — red while stopped',
|
||||
'■\nSTOP',
|
||||
'890',
|
||||
[active('stopped', colors.red)],
|
||||
'18',
|
||||
0x682536,
|
||||
'play',
|
||||
),
|
||||
transport_stop: button('Stop — red while stopped', '■\nSTOP', '890', [], '18', 'stop'),
|
||||
// Verified against MPC-HC 2.8.5's /commands.json: 918 is an after-playback setting.
|
||||
transport_previous: button('Previous playlist item', '◀◀\nPREV', '919', [], '18', 0x234e82),
|
||||
transport_next: button('Next playlist item', '▶▶\nNEXT', '920', [], '18', 0x234e82),
|
||||
transport_mute: button(
|
||||
'Toggle mute — red while muted',
|
||||
'MUTE',
|
||||
'909',
|
||||
[active('muted', colors.red, 'MUTED')],
|
||||
'18',
|
||||
0x583578,
|
||||
),
|
||||
transport_pause: button(
|
||||
'Pause — amber while paused',
|
||||
'Ⅱ\nPAUSE',
|
||||
'888',
|
||||
[active('paused', colors.amber)],
|
||||
'18',
|
||||
0x78500e,
|
||||
),
|
||||
transport_previous: button('Previous playlist item', '◀◀\nPREV', '919', [], '18', 'navigation'),
|
||||
transport_next: button('Next playlist item', '▶▶\nNEXT', '920', [], '18', 'navigation'),
|
||||
transport_mute: button('Toggle mute — red while muted', 'MUTE', '909', [active('muted', 'MUTED')], '18', 'mute'),
|
||||
transport_pause: button('Pause — amber while paused', 'Ⅱ\nPAUSE', '888', [], '18', 'pause'),
|
||||
transport_remaining: button(
|
||||
'Remaining time and progress',
|
||||
`LEFT\n$(${label}:remaining)`,
|
||||
null,
|
||||
[{ feedbackId: 'progress_bar', options: {} }],
|
||||
'18',
|
||||
0x164b56,
|
||||
),
|
||||
transport_elapsed: button(
|
||||
'Elapsed time and progress',
|
||||
|
|
@ -115,15 +93,8 @@ export function presets(label = 'MPC_DEV') {
|
|||
null,
|
||||
[{ feedbackId: 'progress_bar', options: {} }],
|
||||
'14',
|
||||
0x164b56,
|
||||
),
|
||||
transport_state: button(
|
||||
'Playback state',
|
||||
`$(${label}:state_label)`,
|
||||
null,
|
||||
[active('playing', colors.green), active('paused', colors.amber), active('stopped', colors.red)],
|
||||
'14',
|
||||
),
|
||||
transport_state: button('Playback state', `$(${label}:state_label)`, null, [], '14', 'state'),
|
||||
}
|
||||
return { ...transport, ...catalog }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,45 @@ export function progressBar(state, image) {
|
|||
}
|
||||
}
|
||||
|
||||
// Transparent center preserves Companion's own text rendering and dark background.
|
||||
export function transportBorder(state, image, control) {
|
||||
if (!image) return {}
|
||||
const width = Math.max(1, Math.min(2048, Math.floor(image.width)))
|
||||
const height = Math.max(1, Math.min(2048, Math.floor(image.height)))
|
||||
if (!Number.isFinite(width) || !Number.isFinite(height)) return {}
|
||||
const palette = { play: colors.green, stop: colors.red, pause: colors.amber, navigation: colors.blue, mute: 0x8965ad }
|
||||
const active =
|
||||
state &&
|
||||
((control === 'play' && ['playing', 'paused'].includes(state.state)) ||
|
||||
(control === 'stop' && state.state === 'stopped') ||
|
||||
(control === 'pause' && state.state === 'paused') ||
|
||||
(control === 'mute' && state.muted) ||
|
||||
(control === 'state' && ['playing', 'paused', 'stopped'].includes(state.state)))
|
||||
let color = palette[control] ?? 0x59636d
|
||||
if (control === 'play' && state?.state === 'paused') color = colors.amber
|
||||
if (control === 'mute' && state?.muted) color = colors.red
|
||||
if (control === 'state')
|
||||
color = { playing: colors.green, paused: colors.amber, stopped: colors.red }[state?.state] ?? 0x59636d
|
||||
if (!state) color = 0x59636d
|
||||
const thickness = Math.max(1, Math.round((Math.min(width, height) * (active ? 3 : 1)) / 72))
|
||||
const pixels = Buffer.alloc(width * height * 4)
|
||||
for (let y = 0; y < height; y++) {
|
||||
for (let x = 0; x < width; x++) {
|
||||
if (x >= thickness && x < width - thickness && y >= thickness && y < height - thickness) continue
|
||||
const offset = (y * width + x) * 4
|
||||
pixels[offset] = (color >> 16) & 255
|
||||
pixels[offset + 1] = (color >> 8) & 255
|
||||
pixels[offset + 2] = color & 255
|
||||
pixels[offset + 3] = 255
|
||||
}
|
||||
}
|
||||
return {
|
||||
imageBuffer: pixels.toString('base64'),
|
||||
imageBufferEncoding: { pixelFormat: 'RGBA' },
|
||||
imageBufferPosition: { x: 0, y: 0, width, height },
|
||||
}
|
||||
}
|
||||
|
||||
export function feedbacks(getState, getSync = () => null) {
|
||||
const boolean = (name, callback, color) => ({
|
||||
type: 'boolean',
|
||||
|
|
@ -59,6 +98,21 @@ export function feedbacks(getState, getSync = () => null) {
|
|||
idle: boolean('No active media (idle)', () => getState()?.state === 'idle', colors.dark),
|
||||
muted: boolean('Audio muted', () => getState()?.muted === true, colors.red),
|
||||
offline: boolean('Status unavailable', () => !getState(), colors.dark),
|
||||
transport_border: {
|
||||
type: 'advanced',
|
||||
name: 'Transport outline — thicker when active',
|
||||
options: [
|
||||
{
|
||||
type: 'dropdown',
|
||||
id: 'control',
|
||||
label: 'Control',
|
||||
default: 'play',
|
||||
choices: ['play', 'stop', 'pause', 'navigation', 'mute', 'state'].map((id) => ({ id, label: id })),
|
||||
},
|
||||
],
|
||||
affectedProperties: ['imageBuffer'],
|
||||
callback: (feedback) => transportBorder(getState(), feedback.image, feedback.options.control),
|
||||
},
|
||||
progress_bar: {
|
||||
type: 'advanced',
|
||||
name: 'Playback progress bar',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { normalizeStatus, parseVariables, variables, clock } from '../src/state.js'
|
||||
import { feedbacks, progressBar } from '../src/feedbacks.js'
|
||||
import { feedbacks, progressBar, transportBorder } from '../src/feedbacks.js'
|
||||
import { presets } from '../src/definitions.js'
|
||||
import { status, htmlStatus } from './fixture.js'
|
||||
|
||||
|
|
@ -62,8 +62,11 @@ test('transport presets use playlist commands and state feedback; time displays
|
|||
assert.equal(buttons[`transport_${preset}`].steps[0].down[0].actionId, command)
|
||||
assert.equal(buttons[`transport_${preset}`].feedbacks.at(-1).feedbackId, 'offline')
|
||||
}
|
||||
assert.equal(buttons.transport_play.feedbacks[0].feedbackId, 'playing')
|
||||
assert.equal(buttons.transport_stop.feedbacks[0].feedbackId, 'stopped')
|
||||
assert.equal(
|
||||
buttons.transport_play.feedbacks.find((f) => f.feedbackId === 'transport_border').options.control,
|
||||
'play',
|
||||
)
|
||||
assert.equal(buttons.transport_stop.feedbacks[0].options.control, 'stop')
|
||||
assert.equal(buttons.transport_mute.feedbacks[0].feedbackId, 'muted')
|
||||
assert.equal(buttons.transport_remaining.style.text, 'LEFT\n$(MY_PLAYER:remaining)')
|
||||
assert.deepEqual(buttons.transport_remaining.steps[0].down, [])
|
||||
|
|
@ -84,3 +87,19 @@ test('progress graphic fills the bottom proportionally and clears when state is
|
|||
)
|
||||
assert.deepEqual(progressBar(null, undefined), {})
|
||||
})
|
||||
|
||||
test('transport outlines leave the center clear, thicken when active, and turn grey offline', () => {
|
||||
const image = { width: 72, height: 72 }
|
||||
const render = (state, control) => Buffer.from(transportBorder(state, image, control).imageBuffer, 'base64')
|
||||
const waiting = render({ state: 'stopped' }, 'play')
|
||||
const playing = render({ state: 'playing' }, 'play')
|
||||
const pixel = (buffer, x, y) => [...buffer.subarray((y * 72 + x) * 4, (y * 72 + x + 1) * 4)]
|
||||
assert.equal(pixel(waiting, 0, 36)[3], 255)
|
||||
assert.equal(pixel(waiting, 1, 36)[3], 0)
|
||||
assert.equal(pixel(playing, 2, 36)[3], 255)
|
||||
assert.equal(pixel(playing, 3, 36)[3], 0)
|
||||
assert.equal(pixel(playing, 36, 36)[3], 0)
|
||||
assert.deepEqual(pixel(render(null, 'play'), 0, 0), [89, 99, 109, 255])
|
||||
assert.deepEqual(pixel(render({ muted: true }, 'mute'), 0, 0), [186, 41, 54, 255])
|
||||
assert.deepEqual(transportBorder(null, undefined, 'play'), {})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue