From bbdbedb76478bc4865164ae12e8b39915ab80734 Mon Sep 17 00:00:00 2001 From: McHauge Date: Sun, 14 Mar 2021 19:57:01 +0100 Subject: [PATCH] Added vMix State Variables --- README.md | 1 + src/activators.js | 29 +++++++++++++++++++++++++++++ src/api.js | 37 +++++++++++++++++++++++++++++++++---- src/variables.js | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 96b797f..aab39bc 100644 --- a/README.md +++ b/README.md @@ -142,5 +142,6 @@ and if there is more than one parameter use "&" as a separator between them like * Added Feedback "Video Call - Video Source" * Added Feedback "Overlay - Overlay on PGM or PRV" * Added Variables for overlay 1-4 (PGM, PRV, Input name, Input NR). Variables on Stingers don't give any benefits +* Added Variables For vMix States (recording, streaming, fullscreen, ect) * Updated Presets with new feedback's and action. * Bugfix: Fixed custom command not working with the new URI encoding. diff --git a/src/activators.js b/src/activators.js index 768ba5f..b47f949 100644 --- a/src/activators.js +++ b/src/activators.js @@ -254,6 +254,35 @@ exports.parseActivactor = function (message) { this.data.status[status] = params[2] === '1'; updateBuffer('feedback', 'status'); + + let state_1; + if (params[1] == '1') {state_1 = 'True'} + else if (params[1] == '0') {state_1 = 'False'} + + switch (params[0]) { + case 'FadeToBlack': + this.setVariable(`ftb_active`, state_1); + break + + case 'Fullscreen': + this.setVariable(`fullscreen_active`, state_1); + break + + case 'External': + this.setVariable(`external_active`, state_1); + break; + + case 'Recording': + this.setVariable(`recording_active`, state_1); + break + + case 'MultiCorder': + this.setVariable(`multicorder_active`, state_1); + break + + default: + break; + } } else if (events.busAudio.includes(params[0])) { diff --git a/src/api.js b/src/api.js index ef50075..394b554 100644 --- a/src/api.js +++ b/src/api.js @@ -9,6 +9,7 @@ exports.parseAPI = function (body) { this.debug('info', JSON.stringify(err)); this.data.connected = false; this.checkFeedbacks('status'); + this.setVariable(`connected_state`, 'False'); } else { const getMix = number => { const mix = { @@ -428,11 +429,39 @@ exports.parseAPI = function (body) { } }); + // Update Status Variables + if (data.connected) { this.setVariable(`connected_state`, 'True'); } + else { this.setVariable(`connected_state`, 'False'); } + + if (data.status.fadeToBlack == true) { this.setVariable(`ftb_active`, 'True'); } + else { this.setVariable(`ftb_active`, 'False'); } + + if (data.status.playList == true) { this.setVariable(`playlist_active`, 'True'); } + else { this.setVariable(`playlist_active`, 'False'); } + + if (data.status.fullscreen == true) { this.setVariable(`fullscreen_active`, 'True'); } + else { this.setVariable(`fullscreen_active`, 'False'); } + + if (data.status.external == true) { this.setVariable(`external_active`, 'True'); } + else { this.setVariable(`external_active`, 'False'); } + + for (let i = 0; i < data.status.stream.length; i++) { + const x = i + 1; + if (data.status.stream[i] == true) { this.setVariable(`stream_${x}_active`, 'True'); } + else { this.setVariable(`stream_${x}_active`, 'False'); } + } + + if (data.status.recording == true) { this.setVariable(`recording_active`, 'True'); } + else { this.setVariable(`recording_active`, 'False'); } + + if (data.status.multiCorder == true) { this.setVariable(`multicorder_active`, 'True'); } + else { this.setVariable(`multicorder_active`, 'False'); } + // Update Overlay Variables data.overlays.forEach(overlay => { let input; - let preview = 'false'; - let program = 'false'; + let preview = 'False'; + let program = 'False'; if (overlay.input != undefined) { input = data.inputs.find(input => input.number == overlay.input); @@ -448,9 +477,9 @@ exports.parseAPI = function (body) { if (overlayActive) { if (overlay.preview) { - preview = 'true'; + preview = 'True'; } else { - program = 'true'; + program = 'True'; } } diff --git a/src/variables.js b/src/variables.js index 65d2c73..eeb081a 100644 --- a/src/variables.js +++ b/src/variables.js @@ -1,6 +1,43 @@ exports.updateVariableDefinitions = function() { const variables = []; + // Add variable for instance Status an other status info + variables.push({ + label: `Connected to vMix`, + name: `connected_state` + }) + variables.push({ + label: `Fade To Black Active`, + name: `ftb_active` + }) + variables.push({ + label: `playList Active`, + name: `playlist_active` + }) + variables.push({ + label: `Fullscreen Output Active`, + name: `fullscreen_active` + }) + variables.push({ + label: `External Output Active`, + name: `external_active` + }) + for (let i = 0; i < this.data.status.stream.length; i++) { + const x = i + 1; + variables.push({ + label: `Stream ${x} Active`, + name: `stream_${x}_active` + }) + } + variables.push({ + label: `Recording Active`, + name: `recording_active` + }) + variables.push({ + label: `MultiCorder Active`, + name: `multicorder_active` + }) + // Add variable for preview and program for each mix this.data.mix.forEach(mix => { if (mix.number !== undefined && mix.active) {