Skip to content

Commit 88e8069

Browse files
fix: more responsive feedback, director presets (#20)
* chore: update deps * fix: more responsive feedback when using local inputs * fix: director presets not populating * chore: cleanup, version up
1 parent 8187c20 commit 88e8069

File tree

9 files changed

+273
-264
lines changed

9 files changed

+273
-264
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
# These are supported funding model platforms
2-
3-
github: bryce-seifert # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4-
patreon: # Replace with a single Patreon username
5-
open_collective: # Replace with a single Open Collective username
6-
ko_fi: # Replace with a single Ko-fi username
7-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9-
liberapay: # Replace with a single Liberapay username
10-
issuehunt: # Replace with a single IssueHunt username
11-
otechie: # Replace with a single Otechie username
12-
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1+
github: bryce-seifert

actions.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ export function getActions() {
55
{ id: 'false', label: 'Mute' },
66
]
77

8-
let mutableChoices_Highlight = [
9-
{ id: 'toggle', label: 'Toggle' },
10-
{ id: 'true', label: 'Highlight' },
11-
{ id: 'false', label: 'Un-highlight' },
12-
]
13-
148
let actions = {
159
speaker: {
1610
name: 'Local: Speaker Control',
@@ -42,7 +36,7 @@ export function getActions() {
4236
},
4337
],
4438
callback: (action) => {
45-
this.sendRequest('mic', null, action.options.value)
39+
this.sendRequest('mic', null, action.options.value, true)
4640
},
4741
},
4842

@@ -59,7 +53,7 @@ export function getActions() {
5953
},
6054
],
6155
callback: (action) => {
62-
this.sendRequest('camera', null, action.options.value)
56+
this.sendRequest('camera', null, action.options.value, true)
6357
},
6458
},
6559

companion/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "vdo-ninja",
44
"shortname": "VDO.Ninja",
55
"description": "vdo-ninja",
6-
"version": "2.2.0",
6+
"version": "2.2.1",
77
"license": "MIT",
88
"repository": "git+https://github.com/bitfocus/companion-module-vdo-ninja.git",
99
"bugs": "https://github.com/bitfocus/companion-module-vdo-ninja/issues",

feedbacks.js

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,17 @@ export function getFeedbacks() {
3838
bgcolor: ColorGreen,
3939
},
4040
callback: (feedback) => {
41-
if (this.states[feedback.options.stream]?.position) {
42-
if (feedback.options.state) {
43-
if (this.states[feedback.options.stream]?.others['mute-guest'] === 1) {
44-
return true
41+
let stream = this.states[feedback.options.stream]
42+
if (stream) {
43+
if (stream.position && !stream.director) {
44+
if (stream?.others?.['mute-guest'] == 1) {
45+
return feedback.options.state ?? false
4546
} else {
46-
return this.states[feedback.options.stream]?.muted
47+
return stream?.muted === feedback.options.state
4748
}
4849
} else {
49-
if (this.states[feedback.options.stream]?.others['mute-guest'] === 1) {
50-
return false
51-
}
52-
return this.states[feedback.options.stream]?.muted === feedback.options.state
50+
return stream?.muted === feedback.options.state
5351
}
54-
} else {
55-
return this.states[feedback.options.stream]?.muted === feedback.options.state
5652
}
5753
},
5854
}
@@ -84,21 +80,17 @@ export function getFeedbacks() {
8480
bgcolor: ColorGreen,
8581
},
8682
callback: (feedback) => {
87-
if (this.states[feedback.options.stream]?.position) {
88-
if (feedback.options.state) {
89-
if (this.states[feedback.options.stream]?.others['hide-guest'] === 1) {
90-
return true
83+
let stream = this.states[feedback.options.stream]
84+
if (stream) {
85+
if (stream.position && !stream.director) {
86+
if (stream?.others?.['hide-guest'] == 1) {
87+
return feedback.options.state ?? false
9188
} else {
92-
return this.states[feedback.options.stream]?.videoMuted
89+
return stream?.videoMuted === feedback.options.state
9390
}
9491
} else {
95-
if (this.states[feedback.options.stream]?.others['hide-guest'] === 1) {
96-
return false
97-
}
98-
return this.states[feedback.options.stream]?.videoMuted === feedback.options.state
92+
return stream?.videoMuted === feedback.options.state
9993
}
100-
} else {
101-
return this.states[feedback.options.stream]?.videoMuted === feedback.options.state
10294
}
10395
},
10496
}

index.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { InstanceBase, runEntrypoint } from '@companion-module/base'
1+
import { InstanceBase, InstanceStatus, runEntrypoint } from '@companion-module/base'
22
import { getActions } from './actions.js'
33
import { getPresets } from './presets.js'
44
import { getVariables, updateVariables } from './variables.js'
@@ -15,7 +15,7 @@ class VDONinjaInstance extends InstanceBase {
1515
}
1616

1717
async init(config) {
18-
this.updateStatus('connecting')
18+
this.updateStatus(InstanceStatus.Connecting)
1919

2020
this.config = config
2121

@@ -118,7 +118,7 @@ class VDONinjaInstance extends InstanceBase {
118118
this.log('info', `Connection opened to VDO.Ninja`)
119119
this.connected = true
120120
}
121-
this.updateStatus('ok')
121+
this.updateStatus(InstanceStatus.Ok)
122122

123123
this.ws.send(`{"join": "${this.config.apiID}" }`)
124124
this.ws.send(`{"action": "getDetails"}`)
@@ -139,7 +139,7 @@ class VDONinjaInstance extends InstanceBase {
139139
this.ws.on('error', (data) => {
140140
if (this.connected !== false) {
141141
this.connected = false
142-
this.updateStatus('connection_failure')
142+
this.updateStatus(InstanceStatus.ConnectionFailure)
143143
if (data?.code == 'ENOTFOUND') {
144144
this.log('error', `Unable to reach ${serverUrl}`)
145145
} else {
@@ -152,7 +152,7 @@ class VDONinjaInstance extends InstanceBase {
152152
})
153153
} else {
154154
this.log('warn', `API ID required to connect to VDO.Ninja, please add one in the module settings`)
155-
this.updateStatus('bad_config', 'Missing API ID')
155+
this.updateStatus(InstanceStatus.BadConfig, 'Missing API ID')
156156
}
157157
}
158158

@@ -166,6 +166,17 @@ class VDONinjaInstance extends InstanceBase {
166166
let data = result[x]
167167
this.processGetDetails(data)
168168
}
169+
} else if (callback.local) {
170+
for (let x in this.states) {
171+
if (this.states[x].localStream) {
172+
let result = callback.result
173+
if (callback.value !== 'toggle') {
174+
this.processUpdate({ streamID: this.states[x].streamID, action: callback.action, value: result })
175+
}
176+
}
177+
}
178+
} else {
179+
//console.log(callback)
169180
}
170181
} else if (message?.update) {
171182
let data = message.update
@@ -186,6 +197,10 @@ class VDONinjaInstance extends InstanceBase {
186197
label = data.label
187198
}
188199

200+
if (data.localStream) {
201+
label = `${label} (Local)`
202+
}
203+
189204
let streamObject = { id: data.streamID, label: label }
190205

191206
if (this.streams.find((o) => o.id === data.streamID)) {
@@ -244,17 +259,20 @@ class VDONinjaInstance extends InstanceBase {
244259
this.ws.send(`{"action": "getDetails"}`)
245260
break
246261
case 'directorMuted':
247-
this.states[data.streamID].others['mute-guest'] = data.value ? 1 : 0
262+
this.states[data.streamID].others['mute-guest'] = data.value ? '1' : '0'
248263
break
249-
case 'directorVideoMuted':
250-
this.states[data.streamID].others['hide-guest'] = data.value ? 1 : 0
264+
case 'directorVideoHide':
265+
this.states[data.streamID].others['hide-guest'] = data.value ? '1' : '0'
251266
break
252267
case 'remoteMuted':
268+
case 'mic':
253269
this.states[data.streamID].muted = data.value
254270
break
255271
case 'remoteVideoMuted':
272+
case 'camera':
256273
this.states[data.streamID].videoMuted = data.value
257274
break
275+
258276
default:
259277
this.states[data.streamID][data.action] = data.value
260278
break
@@ -267,11 +285,12 @@ class VDONinjaInstance extends InstanceBase {
267285
}
268286
}
269287

270-
sendRequest(action, target, value) {
288+
sendRequest(action, target, value, local) {
271289
let object = {
272-
action: action ? action : 'null',
273-
target: target ? target : 'null',
274-
value: value ? value : 'null',
290+
action: action ?? 'null',
291+
target: target ?? 'null',
292+
value: value ?? 'null',
293+
local: local ?? false,
275294
}
276295
this.ws.send(JSON.stringify(object))
277296
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"name": "vdo-ninja",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"main": "index.js",
55
"type": "module",
66
"scripts": {
77
"format": "prettier -w ."
88
},
99
"license": "MIT",
1010
"dependencies": {
11-
"@companion-module/base": "~1.6.0",
12-
"ws": "^8.15.1"
11+
"@companion-module/base": "~1.7.0",
12+
"ws": "^8.16.0"
1313
},
1414
"repository": {
1515
"type": "git",
1616
"url": "git+https://github.com/bitfocus/companion-module-vdo-ninja.git"
1717
},
1818
"devDependencies": {
19-
"@companion-module/tools": "^1.4.1"
19+
"@companion-module/tools": "^1.5.0"
2020
},
2121
"prettier": "@companion-module/tools/.prettierrc.json"
2222
}

presets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function getPresets() {
1212
for (let s in this.states) {
1313
let stream = this.states[s]
1414

15-
if (stream.position) {
15+
if (stream.position && !stream.director) {
1616
presets[`guest_${stream.position}_mic`] = {
1717
type: 'button',
1818
category: 'Guest Actions',

variables.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export function updateVariables() {
3737
})
3838
} else if (data.position) {
3939
this.setVariableValues({
40-
[`guest_${data.position}_mic`]: data.muted || data.others['mute-guest'] == 1 ? 'Muted' : 'Unmuted',
41-
[`guest_${data.position}_camera`]: data.videoMuted || data.others['hide-guest'] == 1 ? 'Muted' : 'Unmuted',
40+
[`guest_${data.position}_mic`]: data.muted || data.others?.['mute-guest'] == 1 ? 'Muted' : 'Unmuted',
41+
[`guest_${data.position}_camera`]: data.videoMuted || data.others?.['hide-guest'] == 1 ? 'Muted' : 'Unmuted',
4242
[`guest_${data.position}_label`]: label,
4343
})
4444
} else {

0 commit comments

Comments
 (0)