2016-08-09 20:04:40 +00:00
|
|
|
/* global APP, $, config, interfaceConfig, JitsiMeetJS */
|
2016-03-29 18:10:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright @ 2015 Atlassian Pty Ltd
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2016-11-11 15:00:54 +00:00
|
|
|
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
|
|
|
2016-03-29 18:10:31 +00:00
|
|
|
import UIEvents from "../../../service/UI/UIEvents";
|
|
|
|
import UIUtil from '../util/UIUtil';
|
2016-04-26 21:38:07 +00:00
|
|
|
import VideoLayout from '../videolayout/VideoLayout';
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2017-04-12 19:06:56 +00:00
|
|
|
import { setToolboxEnabled } from '../../../react/features/toolbox';
|
2017-08-02 18:15:55 +00:00
|
|
|
import { setNotificationsEnabled } from '../../../react/features/notifications';
|
2017-08-25 16:45:30 +00:00
|
|
|
import {
|
|
|
|
hideRecordingLabel,
|
|
|
|
updateRecordingState
|
|
|
|
} from '../../../react/features/recording';
|
|
|
|
|
|
|
|
const Status = JitsiMeetJS.constants.recordingStatus;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translation keys to use for display in the UI when recording the conference
|
|
|
|
* but not streaming live.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
export const RECORDING_TRANSLATION_KEYS = {
|
|
|
|
failedToStartKey: 'recording.failedToStart',
|
|
|
|
recordingBusy: 'liveStreaming.busy',
|
|
|
|
recordingButtonTooltip: 'recording.buttonTooltip',
|
|
|
|
recordingErrorKey: 'recording.error',
|
|
|
|
recordingOffKey: 'recording.off',
|
|
|
|
recordingOnKey: 'recording.on',
|
|
|
|
recordingPendingKey: 'recording.pending',
|
|
|
|
recordingTitle: 'dialog.recording',
|
|
|
|
recordingUnavailable: 'recording.unavailable'
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translation keys to use for display in the UI when the recording mode is
|
|
|
|
* currently streaming live.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
export const STREAMING_TRANSLATION_KEYS = {
|
|
|
|
failedToStartKey: 'liveStreaming.failedToStart',
|
|
|
|
recordingBusy: 'liveStreaming.busy',
|
|
|
|
recordingButtonTooltip: 'liveStreaming.buttonTooltip',
|
|
|
|
recordingErrorKey: 'liveStreaming.error',
|
|
|
|
recordingOffKey: 'liveStreaming.off',
|
|
|
|
recordingOnKey: 'liveStreaming.on',
|
|
|
|
recordingPendingKey: 'liveStreaming.pending',
|
|
|
|
recordingTitle: 'dialog.liveStreaming',
|
|
|
|
recordingUnavailable: 'liveStreaming.unavailable'
|
|
|
|
};
|
2016-04-26 21:38:07 +00:00
|
|
|
|
2016-07-06 18:26:27 +00:00
|
|
|
/**
|
|
|
|
* The dialog for user input.
|
|
|
|
*/
|
|
|
|
let dialog = null;
|
2016-03-29 18:10:31 +00:00
|
|
|
|
|
|
|
/**
|
2016-03-29 22:26:39 +00:00
|
|
|
* Indicates if the recording button should be enabled.
|
|
|
|
*
|
|
|
|
* @returns {boolean} {true} if the
|
|
|
|
* @private
|
2016-03-29 18:10:31 +00:00
|
|
|
*/
|
|
|
|
function _isRecordingButtonEnabled() {
|
2017-04-12 19:06:56 +00:00
|
|
|
return (
|
|
|
|
interfaceConfig.TOOLBAR_BUTTONS.indexOf("recording") !== -1
|
|
|
|
&& config.enableRecording
|
|
|
|
&& APP.conference.isRecordingSupported());
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request live stream token from the user.
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
function _requestLiveStreamId() {
|
2016-03-29 21:07:01 +00:00
|
|
|
const cancelButton
|
|
|
|
= APP.translation.generateTranslationHTML("dialog.Cancel");
|
|
|
|
const backButton = APP.translation.generateTranslationHTML("dialog.Back");
|
|
|
|
const startStreamingButton
|
|
|
|
= APP.translation.generateTranslationHTML("dialog.startLiveStreaming");
|
|
|
|
const streamIdRequired
|
|
|
|
= APP.translation.generateTranslationHTML(
|
|
|
|
"liveStreaming.streamIdRequired");
|
2017-02-14 22:07:12 +00:00
|
|
|
const streamIdHelp
|
|
|
|
= APP.translation.generateTranslationHTML(
|
|
|
|
"liveStreaming.streamIdHelp");
|
2016-03-29 21:07:01 +00:00
|
|
|
|
2016-03-29 18:10:31 +00:00
|
|
|
return new Promise(function (resolve, reject) {
|
2016-07-06 18:26:27 +00:00
|
|
|
dialog = APP.UI.messageHandler.openDialogWithStates({
|
2016-03-29 21:07:01 +00:00
|
|
|
state0: {
|
2016-10-21 17:11:22 +00:00
|
|
|
titleKey: "dialog.liveStreaming",
|
2016-03-29 21:07:01 +00:00
|
|
|
html:
|
2016-11-09 16:46:58 +00:00
|
|
|
`<input class="input-control"
|
|
|
|
name="streamId" type="text"
|
2016-03-29 18:10:31 +00:00
|
|
|
data-i18n="[placeholder]dialog.streamKey"
|
2017-02-14 22:07:12 +00:00
|
|
|
autofocus><div style="text-align: right">
|
2017-04-01 05:52:40 +00:00
|
|
|
<a class="helper-link" target="_new"
|
2017-02-15 23:57:57 +00:00
|
|
|
href="${interfaceConfig.LIVE_STREAMING_HELP_LINK}">`
|
|
|
|
+ streamIdHelp
|
|
|
|
+ `</a></div>`,
|
2016-03-29 21:07:01 +00:00
|
|
|
persistent: false,
|
|
|
|
buttons: [
|
|
|
|
{title: cancelButton, value: false},
|
|
|
|
{title: startStreamingButton, value: true}
|
|
|
|
],
|
|
|
|
focus: ':input:first',
|
|
|
|
defaultButton: 1,
|
|
|
|
submit: function (e, v, m, f) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if (v) {
|
|
|
|
if (f.streamId && f.streamId.length > 0) {
|
|
|
|
resolve(UIUtil.escapeHtml(f.streamId));
|
|
|
|
dialog.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dialog.goToState('state1');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
2016-05-23 21:46:41 +00:00
|
|
|
reject(APP.UI.messageHandler.CANCEL);
|
2016-03-29 21:07:01 +00:00
|
|
|
dialog.close();
|
|
|
|
return false;
|
|
|
|
}
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
|
|
|
},
|
2016-03-29 21:07:01 +00:00
|
|
|
|
|
|
|
state1: {
|
2016-10-21 17:11:22 +00:00
|
|
|
titleKey: "dialog.liveStreaming",
|
2016-10-12 00:08:24 +00:00
|
|
|
html: streamIdRequired,
|
2016-03-29 21:07:01 +00:00
|
|
|
persistent: false,
|
|
|
|
buttons: [
|
|
|
|
{title: cancelButton, value: false},
|
|
|
|
{title: backButton, value: true}
|
|
|
|
],
|
|
|
|
focus: ':input:first',
|
|
|
|
defaultButton: 1,
|
2016-10-03 16:12:04 +00:00
|
|
|
submit: function (e, v) {
|
2016-03-29 21:07:01 +00:00
|
|
|
e.preventDefault();
|
|
|
|
if (v === 0) {
|
2016-05-23 21:46:41 +00:00
|
|
|
reject(APP.UI.messageHandler.CANCEL);
|
2016-03-29 21:07:01 +00:00
|
|
|
dialog.close();
|
|
|
|
} else {
|
|
|
|
dialog.goToState('state0');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-06 18:26:27 +00:00
|
|
|
}, {
|
|
|
|
close: function () {
|
|
|
|
dialog = null;
|
|
|
|
}
|
2016-03-29 21:07:01 +00:00
|
|
|
});
|
2016-03-29 18:10:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request recording token from the user.
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2017-04-12 19:06:56 +00:00
|
|
|
function _requestRecordingToken() {
|
2016-10-12 00:08:24 +00:00
|
|
|
let titleKey = "dialog.recordingToken";
|
2017-07-04 10:49:27 +00:00
|
|
|
let msgString = (
|
2016-10-12 00:08:24 +00:00
|
|
|
`<input name="recordingToken" type="text"
|
|
|
|
data-i18n="[placeholder]dialog.token"
|
2016-11-09 16:46:58 +00:00
|
|
|
class="input-control"
|
2016-10-21 17:11:22 +00:00
|
|
|
autofocus>`
|
2016-10-12 00:08:24 +00:00
|
|
|
);
|
2016-03-29 18:10:31 +00:00
|
|
|
return new Promise(function (resolve, reject) {
|
2016-10-12 00:08:24 +00:00
|
|
|
dialog = APP.UI.messageHandler.openTwoButtonDialog({
|
|
|
|
titleKey,
|
2017-07-04 10:49:27 +00:00
|
|
|
msgString,
|
2016-10-12 00:08:24 +00:00
|
|
|
leftButtonKey: 'dialog.Save',
|
|
|
|
submitFunction: function (e, v, m, f) {
|
2016-03-29 18:10:31 +00:00
|
|
|
if (v && f.recordingToken) {
|
|
|
|
resolve(UIUtil.escapeHtml(f.recordingToken));
|
|
|
|
} else {
|
2016-05-23 21:46:41 +00:00
|
|
|
reject(APP.UI.messageHandler.CANCEL);
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
|
|
|
},
|
2016-10-12 00:08:24 +00:00
|
|
|
closeFunction: function () {
|
2016-07-06 18:26:27 +00:00
|
|
|
dialog = null;
|
|
|
|
},
|
2016-10-12 00:08:24 +00:00
|
|
|
focus: ':input:first'
|
|
|
|
});
|
2016-03-29 18:10:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-04-07 18:09:19 +00:00
|
|
|
/**
|
|
|
|
* Shows a prompt dialog to the user when they have toggled off the recording.
|
|
|
|
*
|
|
|
|
* @param recordingType the recording type
|
|
|
|
* @returns {Promise}
|
|
|
|
* @private
|
|
|
|
*/
|
2017-04-12 19:06:56 +00:00
|
|
|
function _showStopRecordingPrompt(recordingType) {
|
2016-03-29 18:10:31 +00:00
|
|
|
var title;
|
|
|
|
var message;
|
|
|
|
var buttonKey;
|
|
|
|
if (recordingType === "jibri") {
|
|
|
|
title = "dialog.liveStreaming";
|
|
|
|
message = "dialog.stopStreamingWarning";
|
|
|
|
buttonKey = "dialog.stopLiveStreaming";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
title = "dialog.recording";
|
|
|
|
message = "dialog.stopRecordingWarning";
|
|
|
|
buttonKey = "dialog.stopRecording";
|
|
|
|
}
|
|
|
|
|
2017-04-12 19:06:56 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2016-10-12 00:08:24 +00:00
|
|
|
dialog = APP.UI.messageHandler.openTwoButtonDialog({
|
|
|
|
titleKey: title,
|
2016-10-26 21:08:55 +00:00
|
|
|
msgKey: message,
|
2016-10-12 00:08:24 +00:00
|
|
|
leftButtonKey: buttonKey,
|
2017-04-12 19:06:56 +00:00
|
|
|
submitFunction: (e, v) => (v ? resolve : reject)(),
|
|
|
|
closeFunction: () => {
|
2016-07-06 18:26:27 +00:00
|
|
|
dialog = null;
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
2016-10-12 00:08:24 +00:00
|
|
|
});
|
2016-03-29 18:10:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-07-08 12:50:09 +00:00
|
|
|
/**
|
|
|
|
* Checks whether if the given status is either PENDING or RETRYING
|
|
|
|
* @param status {Status} Jibri status to be checked
|
|
|
|
* @returns {boolean} true if the condition is met or false otherwise.
|
|
|
|
*/
|
|
|
|
function isStartingStatus(status) {
|
|
|
|
return status === Status.PENDING || status === Status.RETRYING;
|
|
|
|
}
|
|
|
|
|
2016-04-07 18:09:19 +00:00
|
|
|
/**
|
|
|
|
* Manages the recording user interface and user experience.
|
|
|
|
* @type {{init, initRecordingButton, showRecordingButton, updateRecordingState,
|
2016-05-03 20:05:09 +00:00
|
|
|
* updateRecordingUI, checkAutoRecord}}
|
2016-04-07 18:09:19 +00:00
|
|
|
*/
|
2016-03-29 18:10:31 +00:00
|
|
|
var Recording = {
|
|
|
|
/**
|
|
|
|
* Initializes the recording UI.
|
|
|
|
*/
|
2017-04-12 19:06:56 +00:00
|
|
|
init(eventEmitter, recordingType) {
|
|
|
|
this.eventEmitter = eventEmitter;
|
|
|
|
this.recordingType = recordingType;
|
2016-05-03 20:05:09 +00:00
|
|
|
|
|
|
|
this.updateRecordingState(APP.conference.getRecordingState());
|
2016-03-29 18:10:31 +00:00
|
|
|
|
|
|
|
if (recordingType === 'jibri') {
|
|
|
|
this.baseClass = "fa fa-play-circle";
|
2017-08-25 16:45:30 +00:00
|
|
|
Object.assign(this, STREAMING_TRANSLATION_KEYS);
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.baseClass = "icon-recEnable";
|
2017-08-25 16:45:30 +00:00
|
|
|
Object.assign(this, RECORDING_TRANSLATION_KEYS);
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
|
|
|
|
2017-04-12 19:06:56 +00:00
|
|
|
// XXX Due to the React-ification of Toolbox, the HTMLElement with id
|
|
|
|
// toolbar_button_record may not exist yet.
|
|
|
|
$(document).on(
|
|
|
|
'click',
|
|
|
|
'#toolbar_button_record',
|
|
|
|
ev => this._onToolbarButtonClick(ev));
|
|
|
|
|
|
|
|
// If I am a recorder then I publish my recorder custom role to notify
|
|
|
|
// everyone.
|
|
|
|
if (config.iAmRecorder) {
|
|
|
|
VideoLayout.enableDeviceAvailabilityIcons(
|
|
|
|
APP.conference.getMyUserId(), false);
|
|
|
|
VideoLayout.setLocalVideoVisible(false);
|
|
|
|
APP.store.dispatch(setToolboxEnabled(false));
|
2017-08-02 18:15:55 +00:00
|
|
|
APP.store.dispatch(setNotificationsEnabled(false));
|
2017-04-12 19:06:56 +00:00
|
|
|
APP.UI.messageHandler.enablePopups(false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise the recording button.
|
|
|
|
*/
|
|
|
|
initRecordingButton() {
|
|
|
|
const selector = $('#toolbar_button_record');
|
|
|
|
|
2016-03-29 18:10:31 +00:00
|
|
|
selector.addClass(this.baseClass);
|
2016-03-29 21:07:01 +00:00
|
|
|
selector.attr("data-i18n", "[content]" + this.recordingButtonTooltip);
|
2016-10-21 17:11:22 +00:00
|
|
|
APP.translation.translateElement(selector);
|
2016-03-29 18:10:31 +00:00
|
|
|
},
|
|
|
|
|
2016-04-07 18:09:19 +00:00
|
|
|
/**
|
|
|
|
* Shows or hides the 'recording' button.
|
|
|
|
* @param show {true} to show the recording button, {false} to hide it
|
|
|
|
*/
|
2017-04-12 19:06:56 +00:00
|
|
|
showRecordingButton(show) {
|
2016-11-11 10:27:29 +00:00
|
|
|
let shouldShow = show && _isRecordingButtonEnabled();
|
2016-11-04 13:58:43 +00:00
|
|
|
let id = 'toolbar_button_record';
|
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(id, shouldShow);
|
2016-03-29 18:10:31 +00:00
|
|
|
},
|
|
|
|
|
2016-04-07 18:09:19 +00:00
|
|
|
/**
|
|
|
|
* Updates the recording state UI.
|
|
|
|
* @param recordingState gives us the current recording state
|
|
|
|
*/
|
2016-06-02 22:12:40 +00:00
|
|
|
updateRecordingState(recordingState) {
|
2016-03-29 22:26:39 +00:00
|
|
|
// I'm the recorder, so I don't want to see any UI related to states.
|
|
|
|
if (config.iAmRecorder)
|
|
|
|
return;
|
|
|
|
|
2016-03-29 18:46:10 +00:00
|
|
|
// If there's no state change, we ignore the update.
|
2016-05-03 20:05:09 +00:00
|
|
|
if (!recordingState || this.currentState === recordingState)
|
2016-03-29 18:46:10 +00:00
|
|
|
return;
|
|
|
|
|
2016-06-02 22:12:40 +00:00
|
|
|
this.updateRecordingUI(recordingState);
|
2016-03-29 18:10:31 +00:00
|
|
|
},
|
|
|
|
|
2016-04-07 18:09:19 +00:00
|
|
|
/**
|
|
|
|
* Sets the state of the recording button.
|
|
|
|
* @param recordingState gives us the current recording state
|
|
|
|
*/
|
2017-04-12 19:06:56 +00:00
|
|
|
updateRecordingUI(recordingState) {
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2016-06-02 16:30:45 +00:00
|
|
|
let oldState = this.currentState;
|
|
|
|
this.currentState = recordingState;
|
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
let labelDisplayConfiguration;
|
|
|
|
|
|
|
|
switch (recordingState) {
|
|
|
|
case Status.ON:
|
|
|
|
case Status.RETRYING: {
|
|
|
|
labelDisplayConfiguration = {
|
|
|
|
centered: false,
|
|
|
|
key: this.recordingOnKey,
|
|
|
|
showSpinner: recordingState === Status.RETRYING
|
|
|
|
};
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2016-10-06 21:25:15 +00:00
|
|
|
this._setToolbarButtonToggled(true);
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
break;
|
2016-05-05 16:14:27 +00:00
|
|
|
}
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
case Status.OFF:
|
|
|
|
case Status.BUSY:
|
|
|
|
case Status.FAILED:
|
|
|
|
case Status.UNAVAILABLE: {
|
|
|
|
const wasInStartingStatus = isStartingStatus(oldState);
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
// We don't want UI changes if this is an availability change.
|
|
|
|
if (oldState !== Status.ON && !wasInStartingStatus) {
|
|
|
|
APP.store.dispatch(updateRecordingState({ recordingState }));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
labelDisplayConfiguration = {
|
|
|
|
centered: true,
|
|
|
|
key: wasInStartingStatus
|
|
|
|
? this.failedToStartKey
|
|
|
|
: this.recordingOffKey
|
|
|
|
};
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
this._setToolbarButtonToggled(false);
|
2016-03-29 18:10:31 +00:00
|
|
|
|
|
|
|
setTimeout(function(){
|
2017-08-25 16:45:30 +00:00
|
|
|
APP.store.dispatch(hideRecordingLabel());
|
2016-03-29 18:10:31 +00:00
|
|
|
}, 5000);
|
2017-08-25 16:45:30 +00:00
|
|
|
|
|
|
|
break;
|
2016-03-29 18:46:10 +00:00
|
|
|
}
|
2017-08-25 16:45:30 +00:00
|
|
|
|
|
|
|
case Status.PENDING: {
|
|
|
|
labelDisplayConfiguration = {
|
|
|
|
centered: true,
|
|
|
|
key: this.recordingPendingKey
|
|
|
|
};
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2016-10-06 21:25:15 +00:00
|
|
|
this._setToolbarButtonToggled(false);
|
2016-03-29 18:10:31 +00:00
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
break;
|
2016-05-05 16:14:27 +00:00
|
|
|
}
|
2017-08-25 16:45:30 +00:00
|
|
|
|
|
|
|
case Status.ERROR: {
|
|
|
|
labelDisplayConfiguration = {
|
|
|
|
centered: true,
|
|
|
|
key: this.recordingErrorKey
|
|
|
|
};
|
2016-10-06 21:25:15 +00:00
|
|
|
|
|
|
|
this._setToolbarButtonToggled(false);
|
2016-05-05 16:14:27 +00:00
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
break;
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
// Return an empty label display configuration to indicate no label
|
|
|
|
// should be displayed. The Status.AVAIABLE case is handled here.
|
|
|
|
default: {
|
|
|
|
labelDisplayConfiguration = null;
|
|
|
|
}
|
|
|
|
}
|
2016-07-08 12:50:09 +00:00
|
|
|
|
2017-08-25 16:45:30 +00:00
|
|
|
APP.store.dispatch(updateRecordingState({
|
|
|
|
labelDisplayConfiguration,
|
|
|
|
recordingState
|
|
|
|
}));
|
2016-03-29 18:10:31 +00:00
|
|
|
},
|
2017-08-25 16:45:30 +00:00
|
|
|
|
2016-03-29 18:10:31 +00:00
|
|
|
// checks whether recording is enabled and whether we have params
|
|
|
|
// to start automatically recording
|
2017-04-12 19:06:56 +00:00
|
|
|
checkAutoRecord() {
|
2016-03-29 18:10:31 +00:00
|
|
|
if (_isRecordingButtonEnabled && config.autoRecord) {
|
|
|
|
this.predefinedToken = UIUtil.escapeHtml(config.autoRecordToken);
|
|
|
|
this.eventEmitter.emit(UIEvents.RECORDING_TOGGLED,
|
|
|
|
this.predefinedToken);
|
|
|
|
}
|
2016-05-05 16:14:27 +00:00
|
|
|
},
|
2016-10-06 21:25:15 +00:00
|
|
|
|
2017-04-12 19:06:56 +00:00
|
|
|
/**
|
|
|
|
* Handles {@code click} on {@code toolbar_button_record}.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onToolbarButtonClick() {
|
|
|
|
if (dialog) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
JitsiMeetJS.analytics.sendEvent('recording.clicked');
|
|
|
|
switch (this.currentState) {
|
|
|
|
case Status.ON:
|
|
|
|
case Status.RETRYING:
|
|
|
|
case Status.PENDING: {
|
|
|
|
_showStopRecordingPrompt(this.recordingType).then(
|
|
|
|
() => {
|
|
|
|
this.eventEmitter.emit(UIEvents.RECORDING_TOGGLED);
|
|
|
|
JitsiMeetJS.analytics.sendEvent('recording.stopped');
|
|
|
|
},
|
|
|
|
() => {});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Status.AVAILABLE:
|
|
|
|
case Status.OFF: {
|
|
|
|
if (this.recordingType === 'jibri')
|
|
|
|
_requestLiveStreamId().then(streamId => {
|
|
|
|
this.eventEmitter.emit(
|
|
|
|
UIEvents.RECORDING_TOGGLED,
|
|
|
|
{ streamId });
|
|
|
|
JitsiMeetJS.analytics.sendEvent('recording.started');
|
|
|
|
}).catch(reason => {
|
|
|
|
if (reason !== APP.UI.messageHandler.CANCEL)
|
|
|
|
logger.error(reason);
|
|
|
|
else
|
|
|
|
JitsiMeetJS.analytics.sendEvent('recording.canceled');
|
|
|
|
});
|
|
|
|
else {
|
|
|
|
if (this.predefinedToken) {
|
|
|
|
this.eventEmitter.emit(
|
|
|
|
UIEvents.RECORDING_TOGGLED,
|
|
|
|
{ token: this.predefinedToken });
|
|
|
|
JitsiMeetJS.analytics.sendEvent('recording.started');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_requestRecordingToken().then((token) => {
|
|
|
|
this.eventEmitter.emit(
|
|
|
|
UIEvents.RECORDING_TOGGLED,
|
|
|
|
{ token });
|
|
|
|
JitsiMeetJS.analytics.sendEvent('recording.started');
|
|
|
|
}).catch(reason => {
|
|
|
|
if (reason !== APP.UI.messageHandler.CANCEL)
|
|
|
|
logger.error(reason);
|
|
|
|
else
|
|
|
|
JitsiMeetJS.analytics.sendEvent('recording.canceled');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Status.BUSY: {
|
|
|
|
dialog = APP.UI.messageHandler.openMessageDialog(
|
|
|
|
this.recordingTitle,
|
|
|
|
this.recordingBusy,
|
|
|
|
null,
|
|
|
|
() => {
|
|
|
|
dialog = null;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
dialog = APP.UI.messageHandler.openMessageDialog(
|
|
|
|
this.recordingTitle,
|
|
|
|
this.recordingUnavailable,
|
|
|
|
null,
|
|
|
|
() => {
|
|
|
|
dialog = null;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-10-06 21:25:15 +00:00
|
|
|
/**
|
|
|
|
* Sets the toggled state of the recording toolbar button.
|
|
|
|
*
|
|
|
|
* @param {boolean} isToggled indicates if the button should be toggled
|
|
|
|
* or not
|
|
|
|
*/
|
|
|
|
_setToolbarButtonToggled(isToggled) {
|
2016-10-07 18:55:27 +00:00
|
|
|
$("#toolbar_button_record").toggleClass("toggled", isToggled);
|
2016-03-29 18:10:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Recording;
|