From b65ab1aeefbd4d8bb0661ccb8c5ce6134b9d0bd3 Mon Sep 17 00:00:00 2001 From: zoton2 Date: Sat, 24 Feb 2024 15:15:00 +0100 Subject: [PATCH] Add companion button to end videos early --- companion-plugin/companion-module-esa/src/actions.ts | 8 ++++++++ src/extension/companion.ts | 4 +++- src/extension/intermission-player.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/companion-plugin/companion-module-esa/src/actions.ts b/companion-plugin/companion-module-esa/src/actions.ts index a35bd347..eb42ca82 100644 --- a/companion-plugin/companion-module-esa/src/actions.ts +++ b/companion-plugin/companion-module-esa/src/actions.ts @@ -109,6 +109,14 @@ function initActions(instance: ModuleInstance, videos?: { name: string, sum: str } }, }, + video_stop: { + name: 'Video Stop', + description: 'Stops any videos playing, to be used in emergencies', + options: [], + callback: () => { + instance.wsSend({ name: 'video_stop' }); + }, + }, }); } diff --git a/src/extension/companion.ts b/src/extension/companion.ts index 97d93085..c99c333e 100644 --- a/src/extension/companion.ts +++ b/src/extension/companion.ts @@ -1,4 +1,4 @@ -import { startPlaylist } from './intermission-player'; +import { player, startPlaylist } from './intermission-player'; import companion from './util/companion'; import { wait } from './util/helpers'; import { get as nodecg } from './util/nodecg'; @@ -141,5 +141,7 @@ companion.evt.on('action', async (name, value) => { await startPlaylist(); } } + } else if (name === 'video_stop') { + await player.endPlaylistEarly(); } }); diff --git a/src/extension/intermission-player.ts b/src/extension/intermission-player.ts index 7303c049..abe659b4 100644 --- a/src/extension/intermission-player.ts +++ b/src/extension/intermission-player.ts @@ -11,7 +11,7 @@ import { assetsVideos, obsData, videoPlayer } from './util/replicants'; import { sc } from './util/speedcontrol'; const config = nodecg().bundleConfig; -const player = new Player(nodecg(), config.obs, obs); +export const player = new Player(nodecg(), config.obs, obs); // Reset replicant values on startup. videoPlayer.value.playing = false;