-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathactions.js
More file actions
324 lines (301 loc) · 7.06 KB
/
actions.js
File metadata and controls
324 lines (301 loc) · 7.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
export function updateActions() {
let actions = {}
actions['stream'] = {
name: 'Streaming Control',
options: [
{
type: 'dropdown',
label: 'State',
id: 'stream_control',
default: 'Start',
choices: [
{ id: 'Start', label: 'Start' },
{ id: 'Stop', label: 'Stop' },
{ id: 'Toggle', label: 'Toggle' },
],
},
],
callback: ({ options }) => {
var cmd = 'STREAM STATE:\nAction: '
if (options.stream_control === 'Toggle') {
if (this.streaming === 'Streaming' || this.streaming === 'Connecting') {
cmd = cmd + 'Stop\n\n'
} else {
cmd = cmd + 'Start\n\n'
}
} else {
cmd = cmd + options.stream_control + '\n\n'
}
this.sendCommand(cmd)
},
}
actions['stream_settings'] = {
name: 'Stream Settings',
options: [
{
type: 'dropdown',
label: 'Video Mode',
id: 'video_mode',
default: 'Auto',
choices: this.formats,
},
{
type: 'dropdown',
label: 'Platform',
id: 'platform',
choices: this.platforms,
},
{
type: 'textinput',
label: 'Server',
id: 'server',
default: '',
useVariables: true,
tooltip:
'Depends on platform.\nRefer to Blackmagic Web Presenter desktop application for possible options. You may use Companion variables.',
},
{
type: 'textinput',
label: 'Stream Key',
id: 'key',
default: '',
useVariables: true,
tooltip: 'Provided by the streaming platform. You may use Companion variables.',
},
{
type: 'dropdown',
label: 'Quality',
id: 'quality',
default: 'Streaming Medium',
choices: this.quality,
},
],
callback: async (action, context) => {
if (action.options.server == '') {
this.log('warn', 'Server parameter is missing from Stream Settings')
}
if (action.options.key == '') {
this.log('warn', 'Stream Key parameter is missing from Stream Settings')
}
var server = await context.parseVariablesInString(action.options.server)
var key = await context.parseVariablesInString(action.options.key)
if (server == '' && action.options.platform == 'Facebook') {
server = 'Default'
}
var cmd =
'STREAM SETTINGS:\nVideo Mode: ' +
action.options.video_mode +
'\n' +
'Current Platform: ' +
action.options.platform +
'\n' +
'Current Server: ' +
server +
'\n' +
'Current Quality Level: ' +
action.options.quality +
'\n' +
'Stream Key: ' +
key +
'\n\n'
this.sendCommand(cmd)
},
}
actions['youtube_settings'] = {
name: 'YouTube Simple Settings',
options: [
{
type: 'static-text',
label: 'All settings are set to YouTube defaults except for the Stream Key',
id: 'info',
},
{
type: 'textinput',
label: 'Stream Key',
id: 'key',
default: '',
useVariables: true,
tooltip: 'Enter the Stream Key from your YouTube creator studio. You may use Companion variables.',
},
],
callback: async (action, context) => {
// find a suitable YouTube platform from available options
var platform = 'YouTube'
const checkRTMP = (obj) => obj.label === 'YouTube RTMP'
if (this.platforms.some(checkRTMP) == true) {
// changed in WebPresenter 3.3
platform = 'YouTube RTMP'
}
const key = await context.parseVariablesInString(action.options.key)
var cmd =
'STREAM SETTINGS:\nVideo Mode: ' +
'Auto' +
'\n' +
'Current Platform: ' +
platform +
'\n' +
'Current Server: ' +
'Primary' +
'\n' +
'Current Quality Level: ' +
'Streaming Medium' +
'\n' +
'Stream Key: ' +
key +
'\n\n'
this.sendCommand(cmd)
},
}
actions['custom_settings'] = {
name: 'Custom URL H.264/H.265 Settings',
options: [
{
type: 'dropdown',
label: 'Platform',
id: 'platform',
choices: this.customPlatforms,
},
{
type: 'dropdown',
label: 'Video Mode',
id: 'video_mode',
default: 'Auto',
choices: this.formats,
},
{
type: 'textinput',
label: 'Custom URL',
id: 'customURL',
default: '',
useVariables: true,
tooltip: 'Enter the URL of the custom server. You may use Companion variables.',
},
{
type: 'textinput',
label: 'Stream Key',
id: 'key',
default: '',
useVariables: true,
tooltip: 'Enter the stream key of the custom server. You may use Companion variables.',
},
{
type: 'dropdown',
label: 'Quality',
id: 'quality',
default: 'Streaming Medium',
choices: this.quality,
},
],
callback: async (action, context) => {
const url = await context.parseVariablesInString(action.options.customURL)
const key = await context.parseVariablesInString(action.options.key)
var cmd =
'STREAM SETTINGS:\nVideo Mode: ' +
action.options.video_mode +
'\n' +
'Current Platform:' +
action.options.platform +
'\n' +
'Current Server: Custom' +
'\n' +
'Current Quality Level: ' +
action.options.quality +
'\n' +
'Current URL:' +
url +
'\n' +
'Stream Key: ' +
key +
'\n\n'
this.sendCommand(cmd)
},
}
actions['device'] = {
name: 'Device Control',
options: [
{
type: 'dropdown',
label: 'State',
id: 'device_control',
default: 'Reboot',
choices: [
{ id: 'Reboot', label: 'Reboot' },
{ id: 'Factory Reset', label: 'Factory Reset' },
],
},
],
callback: ({ options }) => {
var cmd = 'SHUTDOWN:\nAction: ' + options.device_control + '\n\n'
this.sendCommand(cmd)
},
}
actions['videoMode'] = {
name: 'Change Video Mode',
options: [
{
type: 'dropdown',
label: 'Video Mode',
id: 'video_mode',
default: 'Auto',
choices: this.formats,
},
],
callback: ({ options }) => {
var cmd = 'STREAM SETTINGS:\nVideo Mode: ' + options.video_mode + '\n\n'
this.sendCommand(cmd)
},
}
actions['videoQuality'] = {
name: 'Change Video Quality',
options: [
{
type: 'dropdown',
label: 'Quality',
id: 'quality',
default: 'Streaming Medium',
choices: this.quality,
},
],
callback: ({ options }) => {
var cmd = 'STREAM SETTINGS:\nCurrent Quality Level: ' + options.quality + '\n\n'
this.sendCommand(cmd)
},
}
actions['streamKey'] = {
name: 'Change Stream Key',
options: [
{
type: 'textinput',
label: 'Stream Key',
id: 'key',
default: '',
useVariables: true,
tooltip: 'Enter the Stream Key. You may use Companion variables.',
},
],
callback: async (action, context) => {
const key = await context.parseVariablesInString(action.options.key)
var cmd = 'STREAM SETTINGS:\nStream Key: ' + key + '\n\n'
this.sendCommand(cmd)
},
}
actions['passphrase'] = {
name: 'Change SRT Passphrase',
options: [
{
type: 'textinput',
label: 'Passphrase',
id: 'passphrase',
default: '',
useVariables: true,
tooltip: 'You may use Companion variables.',
},
],
callback: async (action, context) => {
const pass = await context.parseVariablesInString(action.options.passphrase)
var cmd = 'STREAM SETTINGS:\nPassword: ' + pass + '\n\n'
this.sendCommand(cmd)
},
}
this.setActionDefinitions(actions)
}