Skip to content

Commit

Permalink
Added vMix State Variables
Browse files Browse the repository at this point in the history
  • Loading branch information
McHauge committed Mar 14, 2021
1 parent 5a08648 commit bbdbedb
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
29 changes: 29 additions & 0 deletions src/activators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
37 changes: 33 additions & 4 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
Expand All @@ -448,9 +477,9 @@ exports.parseAPI = function (body) {

if (overlayActive) {
if (overlay.preview) {
preview = 'true';
preview = 'True';
} else {
program = 'true';
program = 'True';
}
}

Expand Down
37 changes: 37 additions & 0 deletions src/variables.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit bbdbedb

Please sign in to comment.