forked from steveseguin/vdo.ninja
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iframe-examples.js
326 lines (323 loc) · 9.4 KB
/
iframe-examples.js
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
325
326
/**
* SANDBOX EXAMPLE CONFIG
*
* options: (number | boolean | string | null)[]
* - OPTIONAL if using a user input; see "input" below
* - List of values to test (passed into "result" function)
* - An option button will be generated for each value in the list
*
* input: object
* - OPTIONAL
* - User input for testing (eg a range slider).
* - Output of element onchange will be passed into RESULT function.
*
* labels: string[]
* - OPTIONAL
* - List of labels for option buttons (should be same length as options list).
* - If no labels are provided, option buttons are labeled with their value
*
* result: (value: any) => object
* - Function that returns a postMessage object
* - Based on the value produced by an option button, or a user input
*/
const IFRAME_API = {
add: {
options: [true],
labels: ["Video with styles"],
result: value => ({
"target": "*",
"add": value,
"settings": { "style": "width:640px;height:360px;float:left;border:10px solid red;display:block;"}
})
},
automixer: {
options: [true, false],
result: value => ({ "automixer": value })
},
bitrate: {
options: [-1],
labels: ["default (-1)"],
input: {
title: "bitrate",
type: "range",
min: 0,
max: 6000,
value: 3000
},
result: value => ({ "bitrate": value, "target": "*" })
},
camera: {
options: [false, true, "toggle"],
result: value => ({ "camera": value })
},
changeAudioDevice: { // change text of add camera button
options: [1,2,3,4],
result: value => ({ "changeAudioDevice": value })
},
changeVideoDevice: { // change text of add camera button
options: [1,2,3,4],
result: value => ({ "changeVideoDevice": value })
},
close: {
options: [true],
result: value => ({ "close": value })
},
getDetailedState: {
options: [true],
result: value => ({ "getDetailedState": value }),
},
getDeviceList: {
options: [true],
result: value => ({ "getDeviceList": value }),
},
getLoudness: {
options: [false, true],
result: value => ({ "getLoudness": value }),
},
getStreamIDs: {
options: [true],
result: value => ({ "getStreamIDs": value }),
},
keyframe: {
options: [true],
result: value => ({ "keyframe": value }),
},
mute: {
options: [
true,
false,
"toggle" // open to a better suggestion here.
],
result: value => ({ "mute": value }),
},
mic: {
options: [true, false, "toggle"],
result: value => ({ "mic": value }),
},
panning: {
options: [0, 180, 90],
input: {
title: "panning",
type: "range",
min: 0,
max: 180,
value: 90
},
labels: ["Left (0)", "Right (180)", "Center (90)"],
result: value => ({ "panning": value }),
},
previewWebcam: {
options: ["previewWebcam"], // publishScreen
result: value => ({ "function": value }),
},
record: {
options: [true, false],
result: value => ({ "record": value }),
},
reload: {
options: [true],
result: value => ({ "reload": value }),
},
remove: { // target can be a stream ID or * for all.
options: [true],
labels: ["Target video"],
result: value => ({ "target": "*", "remove": value })
},
sendChat: {
input: {
type: "text",
value: "Hello"
},
result: value => ({ "sendChat": value }),
},
sceneState: {
options: [true, false],
labels: ["ENABLE TALLY LIGHT (true)", "STOP TALLY LIGHT (false)"],
result: value => ({ "sceneState": value })
},
style: {
options: ["#main { zoom: 0.5;} video {float: left; margin: 0; padding: 0; } #info {display:none;}"],
labels: ["Insert Style Sheet"],
result: value => ({ "style": value }),
},
volume: {
input: {
title: "volume",
type: "range",
min: 0,
max: 200,
value: 100
},
result: value => ({ "volume": value }),
},
["function: Eval"]: {
options: ["eval"], // publishScreen
result: value => ({ "function": value, "value": 'alert(\"DANGERUS\")' })
},
["function: Change html"]: {
options: ["changeHTML"], // change text of add camera button
result: value => ({ "function": value, "target": "add_camera", "value": "NEW CAMERA TEXT" })
}
}
const COMPANION_API = { // list available commands to console
bitrate: {
input: {
title: "bitrate",
type: "range",
min: 0,
max: 6000,
value: 3000
},
result: value => ({ target: null, action: "bitrate", value })
},
camera: {
options: [false, true, "toggle"],
result: value => ({ target: null, action: "camera", value })
},
forceKeyframe: {
options: [null],
labels: ["Rainbow puke fix"],
result: value => ({ target: null, action: "forceKeyframe", value }),
},
getDetails: {
options: [null],
result: value => ({ target: null, action: "getDetails", value })
},
group: {
options: [1,2,3,4,5,6,7,8],
result: value => ({ target: null, action: "group", value })
},
hangup: {
options: [null],
result: value => ({ target: null, action: "hangup", value })
},
mic: {
options: [false, true, "toggle"],
result: value => ({ target: null, action: "mic", value })
},
panning: {
options: [0, 180, 90],
input: {
title: "panning",
type: "range",
min: 0,
max: 180,
value: 90
},
labels: ["Left (0)", "Right (180)", "Center (90)"],
result: value => ({ target: null, action: "panning", value })
},
record: {
options: [false, true, "toggle"],
result: value => ({ target: null, action: "record", value })
},
reload: {
options: [null],
result: value => ({ target: null, action: "reload", value })
},
sendChat: {
input: {
type: "text",
value: "Hello"
},
result: value => ({ target: null, action: "sendChat", value }),
},
speaker: { // "speaker" also works in the same way
options: [false, true, "toggle"],
result: value => ({ target: null, action: "speaker", value }),
},
togglehand: {
options: [null],
result: value => ({ target: null, action: "togglehand", value }),
},
togglescreenshare: {
options: [null],
result: value => ({ target: null, action: "togglescreenshare", value }),
},
volume: {
input: {
title: "volume",
type: "range",
min: 0,
max: 200,
value: 100
},
result: value => ({ target: null, "action": "volume", value }),
},
}
function guestTargetedAPI(target) {
return {
addScene: {
options: [null,1,2,3,4,5,6,7,8],
input: {
type: "text",
value: "scene321"
},
result: value => ({ "action": "addScene", target, value })
},
display: {
options: [null],
result: value => ({ "action": "display", target, value })
},
forward: {
options: [null],
input: {
type: "text",
value: "room321"
},
result: value => ({ "action": "forward", target, value })
},
forceKeyframe: {
options: [null],
labels: ["Rainbow puke fix"],
result: value => ({ "action": "forceKeyframe", target, value })
},
hangup: {
options: [null],
result: value => ({ "action": "hangup", target, value })
},
group: {
options: [0,1,2,3,4,5,6,7,8],
input: {
type: "text",
value: "group321"
},
result: value => ({ "action": "group", target, value })
},
soloChat: {
options: [null],
result: value => ({ "action": "soloChat", target, value })
},
soloVideo: {
options: [null],
result: value => ({ "action": "soloVideo", target, value })
},
speaker: {
options: [null],
labels: ["Remote speaker"],
result: value =>({ "action": "speaker", target, value })
},
mic: {
options: [null],
result: value =>({ "action": "mic", target, value })
},
muteScene: {
options: [null,1,2,3,4,5,6,7,8],
input: {
type: "text",
value: "scene321"
},
result: value => ({ "action": "muteScene", target, value })
},
volume: {
input: {
title: "volume",
type: "range",
min: 0,
max: 200,
value: 100
},
result: value => ({ "action": "volume", target, value }),
},
}
}