From bb045ec5274bfb6bbdb521678178f619a500fc2e Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 12 Nov 2026 19:36:23 +0100 Subject: [PATCH] Raise Load navigation symbols and enlarge labels --- .../media-player-classic/README.md | 3 + .../media-player-classic/src/definitions.js | 106 +++++++++++++++--- .../media-player-classic/src/feedbacks.js | 22 ++++ .../media-player-classic/test/state.test.js | 23 ++++ 4 files changed, 139 insertions(+), 15 deletions(-) diff --git a/companion-modules/media-player-classic/README.md b/companion-modules/media-player-classic/README.md index cec76a8..4399a9e 100644 --- a/companion-modules/media-player-classic/README.md +++ b/companion-modules/media-player-classic/README.md @@ -248,6 +248,9 @@ two-second result display. **Last load result** retains the outcome as **#1**, * on failures/in-progress; successful results show the video name. `load_result_direction` contains `item_1`, `item_2`, etc. +Load next / previous use separate symbol and label layers, with the symbol raised +to leave room for larger text. Re-add existing copied presets to get the new layout. + Numbered Load presets use Companion 5 layered graphics: a small **↓ LOAD** title above a large item number. Re-add existing copied presets to get this layout; linked presets update automatically. diff --git a/companion-modules/media-player-classic/src/definitions.js b/companion-modules/media-player-classic/src/definitions.js index 94f17c6..733d854 100644 --- a/companion-modules/media-player-classic/src/definitions.js +++ b/companion-modules/media-player-classic/src/definitions.js @@ -107,21 +107,97 @@ export function presets(label = 'MPC_DEV') { steps: [{ down: [], up: [] }], feedbacks: [{ feedbackId: 'load_result', options: {} }], }, - transport_load_next: button( - 'Load next', - '↦\nLOAD\nNEXT', - 'load_next', - [{ feedbackId: 'load_next_status', options: {} }], - 12, - 0x243b50, - ), - transport_load_previous: button( - 'Load previous', - '↤\nLOAD\nPREV', - 'load_previous', - [{ feedbackId: 'load_previous_status', options: {} }], - 12, - 0x243b50, + ...Object.fromEntries( + ['next', 'previous'].map((direction) => [ + `transport_load_${direction}`, + { + type: 'layered', + name: `Load ${direction}`, + canvas: { decoration: 'topbar' }, + elements: [ + { id: 'background', type: 'box', x: 0, y: 0, width: 100, height: 100, color: 0x243b50 }, + { + id: 'icon', + type: 'text', + text: direction === 'next' ? '↦' : '↤', + x: 5, + y: -4, + width: 90, + height: 30, + fontsize: 100, + fontsizeAllowShrink: true, + color: colors.white, + halign: 'center', + valign: 'center', + }, + { + id: 'title', + type: 'text', + text: 'LOAD', + x: 3, + y: 27, + width: 94, + height: 33, + fontsize: 100, + fontsizeAllowShrink: true, + color: colors.white, + halign: 'center', + valign: 'center', + }, + { + id: 'direction', + type: 'text', + text: direction === 'next' ? 'NEXT' : 'PREV', + x: 3, + y: 62, + width: 94, + height: 35, + fontsize: 100, + fontsizeAllowShrink: true, + color: colors.white, + halign: 'center', + valign: 'center', + }, + ], + steps: [{ down: [{ actionId: `load_${direction}`, options: { target: 'both' } }], up: [] }], + feedbacks: [ + ...['loading', 'ready', 'failed'].map((state) => ({ + feedbackId: 'load_direction_state', + options: { direction, state }, + styleOverrides: [ + { + elementId: 'title', + elementProperty: 'text', + override: { loading: 'LOADING', ready: 'LOADED', failed: 'FAILED' }[state], + }, + { + elementId: 'background', + elementProperty: 'color', + override: { loading: colors.amber, ready: colors.blue, failed: colors.red }[state], + }, + ...['icon', 'title', 'direction'].map((elementId) => ({ + elementId, + elementProperty: 'color', + override: state === 'loading' ? colors.dark : colors.white, + })), + ], + })), + { + feedbackId: 'offline', + options: {}, + styleOverrides: [ + { elementId: 'title', elementProperty: 'text', override: 'OFFLINE' }, + { elementId: 'background', elementProperty: 'color', override: colors.dark }, + ...['icon', 'title', 'direction'].map((elementId) => ({ + elementId, + elementProperty: 'color', + override: 0x889099, + })), + ], + }, + ], + }, + ]), ), transport_play: button( 'Play — green while playing', diff --git a/companion-modules/media-player-classic/src/feedbacks.js b/companion-modules/media-player-classic/src/feedbacks.js index 5009f70..8839a1d 100644 --- a/companion-modules/media-player-classic/src/feedbacks.js +++ b/companion-modules/media-player-classic/src/feedbacks.js @@ -121,6 +121,28 @@ export function feedbacks(getState, getSync = () => null, getLoadStatus = () => }, ]), ), + load_direction_state: { + type: 'boolean', + name: 'Load next / previous state', + options: [ + { + type: 'dropdown', + id: 'direction', + label: 'Direction', + default: 'next', + choices: ['next', 'previous'].map((id) => ({ id, label: id })), + }, + { + type: 'dropdown', + id: 'state', + label: 'State', + default: 'loading', + choices: ['loading', 'ready', 'failed'].map((id) => ({ id, label: id })), + }, + ], + defaultStyle: { bgcolor: colors.blue }, + callback: (feedback) => getLoadStatus(feedback.options.direction) === feedback.options.state, + }, load_playlist_item_state: { type: 'boolean', name: 'Load playlist item state', diff --git a/companion-modules/media-player-classic/test/state.test.js b/companion-modules/media-player-classic/test/state.test.js index dd9f448..49d2699 100644 --- a/companion-modules/media-player-classic/test/state.test.js +++ b/companion-modules/media-player-classic/test/state.test.js @@ -161,3 +161,26 @@ test('loaded filename preview uses the basename, wraps and truncates without spl ) assert.equal(fb.load_result.callback().text, 'LOADED\nIntro') }) + +test('layered directional load feedback follows each direction and clears after its result expires', () => { + let current = 'loading' + const definitions = feedbacks( + () => null, + () => null, + (direction) => (direction === 'next' ? current : 'idle'), + ) + const catalog = presets() + for (const state of ['loading', 'ready', 'failed', 'idle']) { + current = state + for (const direction of ['next', 'previous']) { + const preset = catalog[`transport_load_${direction}`] + assert.equal(preset.type, 'layered') + for (const feedback of preset.feedbacks.filter((item) => item.feedbackId === 'load_direction_state')) { + assert.equal( + definitions.load_direction_state.callback(feedback), + direction === 'next' && feedback.options.state === state, + ) + } + } + } +})