|
@@ -32,27 +32,73 @@ function _isRecordingButtonEnabled() {
|
32
|
32
|
* @returns {Promise}
|
33
|
33
|
*/
|
34
|
34
|
function _requestLiveStreamId() {
|
35
|
|
- let msg = APP.translation.generateTranslationHTML("dialog.liveStreaming");
|
36
|
|
- let token = APP.translation.translateString("dialog.streamKey");
|
|
35
|
+ const msg = APP.translation.generateTranslationHTML("dialog.liveStreaming");
|
|
36
|
+ const token = APP.translation.translateString("dialog.streamKey");
|
|
37
|
+ const cancelButton
|
|
38
|
+ = APP.translation.generateTranslationHTML("dialog.Cancel");
|
|
39
|
+ const backButton = APP.translation.generateTranslationHTML("dialog.Back");
|
|
40
|
+ const startStreamingButton
|
|
41
|
+ = APP.translation.generateTranslationHTML("dialog.startLiveStreaming");
|
|
42
|
+ const streamIdRequired
|
|
43
|
+ = APP.translation.generateTranslationHTML(
|
|
44
|
+ "liveStreaming.streamIdRequired");
|
|
45
|
+
|
37
|
46
|
return new Promise(function (resolve, reject) {
|
38
|
|
- APP.UI.messageHandler.openTwoButtonDialog(
|
39
|
|
- null, null, null,
|
40
|
|
- `<h2>${msg}</h2>
|
41
|
|
- <input name="streamId" type="text"
|
|
47
|
+ let dialog = APP.UI.messageHandler.openDialogWithStates({
|
|
48
|
+ state0: {
|
|
49
|
+ html:
|
|
50
|
+ `<h2>${msg}</h2>
|
|
51
|
+ <input name="streamId" type="text"
|
42
|
52
|
data-i18n="[placeholder]dialog.streamKey"
|
43
|
53
|
placeholder="${token}" autofocus>`,
|
44
|
|
- false, "dialog.startLiveStreaming",
|
45
|
|
- function (e, v, m, f) {
|
46
|
|
- if (v && f.streamId) {
|
47
|
|
- resolve(UIUtil.escapeHtml(f.streamId));
|
48
|
|
- } else {
|
49
|
|
- reject();
|
|
54
|
+ persistent: false,
|
|
55
|
+ buttons: [
|
|
56
|
+ {title: cancelButton, value: false},
|
|
57
|
+ {title: startStreamingButton, value: true}
|
|
58
|
+ ],
|
|
59
|
+ focus: ':input:first',
|
|
60
|
+ defaultButton: 1,
|
|
61
|
+ submit: function (e, v, m, f) {
|
|
62
|
+ e.preventDefault();
|
|
63
|
+
|
|
64
|
+ if (v) {
|
|
65
|
+ if (f.streamId && f.streamId.length > 0) {
|
|
66
|
+ resolve(UIUtil.escapeHtml(f.streamId));
|
|
67
|
+ dialog.close();
|
|
68
|
+ return;
|
|
69
|
+ }
|
|
70
|
+ else {
|
|
71
|
+ dialog.goToState('state1');
|
|
72
|
+ return false;
|
|
73
|
+ }
|
|
74
|
+ } else {
|
|
75
|
+ reject();
|
|
76
|
+ dialog.close();
|
|
77
|
+ return false;
|
|
78
|
+ }
|
50
|
79
|
}
|
51
|
80
|
},
|
52
|
|
- null,
|
53
|
|
- function () { },
|
54
|
|
- ':input:first'
|
55
|
|
- );
|
|
81
|
+
|
|
82
|
+ state1: {
|
|
83
|
+ html: `<h2>${msg}</h2> ${streamIdRequired}`,
|
|
84
|
+ persistent: false,
|
|
85
|
+ buttons: [
|
|
86
|
+ {title: cancelButton, value: false},
|
|
87
|
+ {title: backButton, value: true}
|
|
88
|
+ ],
|
|
89
|
+ focus: ':input:first',
|
|
90
|
+ defaultButton: 1,
|
|
91
|
+ submit: function (e, v, m, f) {
|
|
92
|
+ e.preventDefault();
|
|
93
|
+ if (v === 0) {
|
|
94
|
+ reject();
|
|
95
|
+ dialog.close();
|
|
96
|
+ } else {
|
|
97
|
+ dialog.goToState('state0');
|
|
98
|
+ }
|
|
99
|
+ }
|
|
100
|
+ }
|
|
101
|
+ });
|
56
|
102
|
});
|
57
|
103
|
}
|
58
|
104
|
|
|
@@ -129,12 +175,22 @@ function moveToCorner(selector, move) {
|
129
|
175
|
selector.removeClass(moveToCornerClass);
|
130
|
176
|
}
|
131
|
177
|
|
|
178
|
+var Status = {
|
|
179
|
+ ON: "on",
|
|
180
|
+ OFF: "off",
|
|
181
|
+ AVAILABLE: "available",
|
|
182
|
+ UNAVAILABLE: "unavailable",
|
|
183
|
+ PENDING: "pending"
|
|
184
|
+}
|
|
185
|
+
|
132
|
186
|
var Recording = {
|
133
|
187
|
/**
|
134
|
188
|
* Initializes the recording UI.
|
135
|
189
|
*/
|
136
|
190
|
init (emitter, recordingType) {
|
137
|
191
|
this.eventEmitter = emitter;
|
|
192
|
+ // Use recorder states directly from the library.
|
|
193
|
+ this.currentState = Status.UNAVAILABLE;
|
138
|
194
|
|
139
|
195
|
this.initRecordingButton(recordingType);
|
140
|
196
|
},
|
|
@@ -148,6 +204,7 @@ var Recording = {
|
148
|
204
|
this.recordingOffKey = "liveStreaming.off";
|
149
|
205
|
this.recordingPendingKey = "liveStreaming.pending";
|
150
|
206
|
this.failedToStartKey = "liveStreaming.failedToStart";
|
|
207
|
+ this.recordingButtonTooltip = "liveStreaming.buttonTooltip";
|
151
|
208
|
}
|
152
|
209
|
else {
|
153
|
210
|
this.baseClass = "icon-recEnable";
|
|
@@ -155,21 +212,25 @@ var Recording = {
|
155
|
212
|
this.recordingOffKey = "recording.off";
|
156
|
213
|
this.recordingPendingKey = "recording.pending";
|
157
|
214
|
this.failedToStartKey = "recording.failedToStart";
|
|
215
|
+ this.recordingButtonTooltip = "recording.buttonTooltip";
|
158
|
216
|
}
|
159
|
217
|
|
160
|
218
|
selector.addClass(this.baseClass);
|
|
219
|
+ selector.attr("data-i18n", "[content]" + this.recordingButtonTooltip);
|
|
220
|
+ selector.attr("content",
|
|
221
|
+ APP.translation.translateString(this.recordingButtonTooltip));
|
161
|
222
|
|
162
|
223
|
var self = this;
|
163
|
224
|
selector.click(function () {
|
164
|
|
- console.log("BUTTON CLICKED", self.currentState);
|
165
|
225
|
switch (self.currentState) {
|
166
|
|
- case "on": {
|
|
226
|
+ case Status.ON:
|
|
227
|
+ case Status.PENDING: {
|
167
|
228
|
_showStopRecordingPrompt(recordingType).then(() =>
|
168
|
229
|
self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED));
|
169
|
|
- }
|
170
|
230
|
break;
|
171
|
|
- case "available":
|
172
|
|
- case "off": {
|
|
231
|
+ }
|
|
232
|
+ case Status.AVAILABLE:
|
|
233
|
+ case Status.OFF: {
|
173
|
234
|
if (recordingType === 'jibri')
|
174
|
235
|
_requestLiveStreamId().then((streamId) => {
|
175
|
236
|
self.eventEmitter.emit( UIEvents.RECORDING_TOGGLED,
|
|
@@ -187,8 +248,8 @@ var Recording = {
|
187
|
248
|
{token: token});
|
188
|
249
|
});
|
189
|
250
|
}
|
190
|
|
- }
|
191
|
251
|
break;
|
|
252
|
+ }
|
192
|
253
|
default: {
|
193
|
254
|
APP.UI.messageHandler.openMessageDialog(
|
194
|
255
|
"dialog.liveStreaming",
|
|
@@ -222,7 +283,7 @@ var Recording = {
|
222
|
283
|
let labelSelector = $('#recordingLabel');
|
223
|
284
|
|
224
|
285
|
// TODO: handle recording state=available
|
225
|
|
- if (recordingState === 'on') {
|
|
286
|
+ if (recordingState === Status.ON) {
|
226
|
287
|
|
227
|
288
|
buttonSelector.removeClass(this.baseClass);
|
228
|
289
|
buttonSelector.addClass(this.baseClass + " active");
|
|
@@ -231,13 +292,13 @@ var Recording = {
|
231
|
292
|
moveToCorner(labelSelector, true, 3000);
|
232
|
293
|
labelSelector
|
233
|
294
|
.text(APP.translation.translateString(this.recordingOnKey));
|
234
|
|
- } else if (recordingState === 'off'
|
235
|
|
- || recordingState === 'unavailable') {
|
|
295
|
+ } else if (recordingState === Status.OFF
|
|
296
|
+ || recordingState === Status.UNAVAILABLE) {
|
236
|
297
|
|
237
|
298
|
// We don't want to do any changes if this is
|
238
|
299
|
// an availability change.
|
239
|
|
- if (this.currentState === "available"
|
240
|
|
- || this.currentState === "unavailable")
|
|
300
|
+ if (this.currentState === Status.AVAILABLE
|
|
301
|
+ || this.currentState === Status.UNAVAILABLE)
|
241
|
302
|
return;
|
242
|
303
|
|
243
|
304
|
buttonSelector.removeClass(this.baseClass + " active");
|
|
@@ -245,7 +306,7 @@ var Recording = {
|
245
|
306
|
|
246
|
307
|
moveToCorner(labelSelector, false);
|
247
|
308
|
let messageKey;
|
248
|
|
- if (this.currentState === "pending")
|
|
309
|
+ if (this.currentState === Status.PENDING)
|
249
|
310
|
messageKey = this.failedToStartKey;
|
250
|
311
|
else
|
251
|
312
|
messageKey = this.recordingOffKey;
|
|
@@ -257,7 +318,7 @@ var Recording = {
|
257
|
318
|
$('#recordingLabel').css({display: "none"});
|
258
|
319
|
}, 5000);
|
259
|
320
|
}
|
260
|
|
- else if (recordingState === 'pending') {
|
|
321
|
+ else if (recordingState === Status.PENDING) {
|
261
|
322
|
|
262
|
323
|
buttonSelector.removeClass(this.baseClass + " active");
|
263
|
324
|
buttonSelector.addClass(this.baseClass);
|