-
Notifications
You must be signed in to change notification settings - Fork 0
/
Advanced_Selfview_Control_1-0.js
192 lines (178 loc) · 6.79 KB
/
Advanced_Selfview_Control_1-0.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
import xapi from 'xapi';
// Set Selfview Position function
async function setSelfviewPosition(selfviewPosition) {
try {
await xapi.Command.Video.Selfview.Set( {
PIPPosition: selfviewPosition,
});
} catch (error) {
console.error('Not able to set Selfview Position with error:' + error);
}
}
// Set Selfview Mode function
async function setSelfviewMode(selfviewMode) {
try {
await xapi.Command.Video.Selfview.Set( {
Mode: selfviewMode,
});
} catch (error) {
console.error('Not able to set Selfview Mode with error:' + error);
}
}
// Set Selfview Fullscreen function
async function setSelfviewFullscreen(selfviewFullscreen) {
try {
await xapi.Command.Video.Selfview.Set( {
FullscreenMode: selfviewFullscreen,
});
} catch (error) {
console.error('Not able to set Selfview Fullscreen with error:' + error);
}
}
// Set Selfview On Monitor function
async function setSelfviewOnMonitor(selfviewOnMonitor) {
try {
await xapi.Command.Video.Selfview.Set( {
OnMonitorRole: selfviewOnMonitor,
});
} catch (error) {
console.error('Not able to set Selfview Mode with error:' + error);
}
}
async function setSelfviewGUI(modeUI, fullscreenModeUI, onMonitorUI, positionUI) {
try {
await xapi.Command.UserInterface.Extensions.Widget.SetValue( { WidgetId: 'show_selfview', Value: modeUI } );
await xapi.Command.UserInterface.Extensions.Widget.SetValue( { WidgetId: 'fullscreen_selfview', Value: fullscreenModeUI } );
await xapi.Command.UserInterface.Extensions.Widget.SetValue( { WidgetId: 'selfview_on_monitor', Value: onMonitorUI } );
await xapi.Command.UserInterface.Extensions.Widget.SetValue( { WidgetId: 'selfview_position', Value: positionUI } );
//console.log('In setSelfviewGUI function: ' + modeUI + ', ' + fullscreenModeUI + ', ' + onMonitorUI + ', ' + positionUI);
} catch (error) {
console.error('Not able to set Selfview UI Value with error:' + error);
}
}
async function updatingSelfviewConfig() {
try {
var modeUI = await xapi.Status.Video.Selfview.Mode.get();
//console.log('Update Mode UI: ' + modeUI);
var fullscreenModeUI = await xapi.Status.Video.Selfview.FullscreenMode.get();
//console.log('Update Mode UI: ' + fullscreenModeUI);
var onMonitorUI = await xapi.Status.Video.Selfview.OnMonitorRole.get();
//console.log('Update Mode UI: ' + onMonitorUI);
var positionUI = await xapi.Status.Video.Selfview.PIPPosition.get();
//console.log('Update Mode UI: ' + positionUI);
setSelfviewGUI(modeUI, fullscreenModeUI, onMonitorUI, positionUI);
} catch (error) {
console.error('Not able to get Selfview Fullscreen Value with error:' + error);
}
}
function init() {
xapi.Event.UserInterface.Extensions.Panel.Clicked.on((event) => {
if(event.PanelId == 'selfview_panel') {
//console.log('Panel is Clicked');
updatingSelfviewConfig();
}
});
xapi.Event.UserInterface.Extensions.Widget.Action.on((event) => {
if(event.Type =='changed') {
switch(event.WidgetId) { // Input for Selfview Mode On/Off
case 'show_selfview':
if(event.Value == 'on') {
var selfviewMode = "On";
console.log('Show Selfview: ' + selfviewMode);
setSelfviewMode(selfviewMode);
}
else {
var selfviewMode = "Off";
console.log('Show Selfview: ' + selfviewMode);
setSelfviewMode(selfviewMode);
}
break;
case 'fullscreen_selfview':
if(event.Value == 'on') {
var selfviewFullscreen = "On";
console.log('Show Selfview: ' + selfviewFullscreen);
setSelfviewFullscreen(selfviewFullscreen);
}
else {
var selfviewFullscreen = "Off";
console.log('Show Selfview: ' + selfviewFullscreen);
setSelfviewFullscreen(selfviewFullscreen);
}
}
}
else if (event.Type == 'released') {
switch(event.WidgetId) {
case 'selfview_on_monitor':
switch(event.Value) {
case 'First':
var selfviewOnMonitor = event.Value;
console.log('On Monitor:' + selfviewOnMonitor);
setSelfviewOnMonitor(selfviewOnMonitor);
break;
case 'Second':
var selfviewOnMonitor = event.Value;
console.log('On Monitor:' + selfviewOnMonitor);
setSelfviewOnMonitor(selfviewOnMonitor);
break;
case 'Third':
var selfviewOnMonitor = event.Value;
console.log('On Monitor:' + selfviewOnMonitor);
setSelfviewOnMonitor(selfviewOnMonitor);
break;
}
break;
case 'selfview_position':
switch(event.Value) {
case 'UpperLeft':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
setSelfviewPosition(selfviewPosition);
break;
case 'UpperCenter':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
setSelfviewPosition(selfviewPosition);
break;
case 'UpperRight':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
setSelfviewPosition(selfviewPosition);
break;
case 'CenterLeft':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
setSelfviewPosition(selfviewPosition);
break;
case 'CenterCenter':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
updatingSelfviewConfig();
break;
case 'CenterRight':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
setSelfviewPosition(selfviewPosition);
break;
case 'LowerLeft':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
setSelfviewPosition(selfviewPosition);
break;
case 'LowerCenter':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
updatingSelfviewConfig();
break;
case 'LowerRight':
var selfviewPosition = event.Value;
//console.log('Selfview Position:' + selfviewPosition);
setSelfviewPosition(selfviewPosition);
break;
}
break;
}
}
});
updatingSelfviewConfig();
}
init();