Fixes streaming tooltip. Checks if the stream id is not provided and requests the user before starting the recorder.

This commit is contained in:
yanas 2016-03-29 16:07:01 -05:00
parent 8b060e9cc0
commit 39c350cdba
4 changed files with 97 additions and 34 deletions

View File

@ -513,7 +513,7 @@
.moveToCorner { .moveToCorner {
top: 5px; top: 5px;
right: 5px; right: 50px; /*leave free space for the HD label*/
margin-right: 0px; margin-right: 0px;
margin-left: auto; margin-left: auto;
background: rgba(0,0,0,.3); background: rgba(0,0,0,.3);

View File

@ -116,7 +116,7 @@
</span> </span>
<a class="button icon-microphone" id="toolbar_button_mute" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="mutePopover" data-i18n="[content]toolbar.mute" content="Mute / Unmute"></a> <a class="button icon-microphone" id="toolbar_button_mute" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="mutePopover" data-i18n="[content]toolbar.mute" content="Mute / Unmute"></a>
<a class="button icon-camera" id="toolbar_button_camera" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleVideoPopover" data-i18n="[content]toolbar.videomute" content="Start / stop camera"></a> <a class="button icon-camera" id="toolbar_button_camera" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleVideoPopover" data-i18n="[content]toolbar.videomute" content="Start / stop camera"></a>
<a class="button" id="toolbar_button_record" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.record" content="Record" style="display: none"></a> <a class="button" id="toolbar_button_record" data-container="body" data-toggle="popover" data-placement="bottom" style="display: none"></a>
<a class="button icon-security" id="toolbar_button_security" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.lock" content="Lock / unlock room"></a> <a class="button icon-security" id="toolbar_button_security" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.lock" content="Lock / unlock room"></a>
<a class="button icon-link" id="toolbar_button_link" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.invite" content="Invite others"></a> <a class="button icon-link" id="toolbar_button_link" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.invite" content="Invite others"></a>
<a class="button icon-chat" id="toolbar_button_chat" data-container="body" data-toggle="popover" shortcut="toggleChatPopover" data-placement="bottom" data-i18n="[content]toolbar.chat" content="Open / close chat"> <a class="button icon-chat" id="toolbar_button_chat" data-container="body" data-toggle="popover" shortcut="toggleChatPopover" data-placement="bottom" data-i18n="[content]toolbar.chat" content="Open / close chat">

View File

@ -51,7 +51,6 @@
"mute": "Mute / Unmute", "mute": "Mute / Unmute",
"videomute": "Start / stop camera", "videomute": "Start / stop camera",
"authenticate": "Authenticate", "authenticate": "Authenticate",
"record": "Toggle recording",
"lock": "Lock / unlock room", "lock": "Lock / unlock room",
"invite": "Invite others", "invite": "Invite others",
"chat": "Open / close chat", "chat": "Open / close chat",
@ -264,7 +263,8 @@
"pending": "Recording waiting for a participant to join...", "pending": "Recording waiting for a participant to join...",
"on": "Recording", "on": "Recording",
"off": "Recording stopped", "off": "Recording stopped",
"failedToStart": "Recording failed to start" "failedToStart": "Recording failed to start",
"buttonTooltip": "Start / stop recording"
}, },
"liveStreaming": "liveStreaming":
{ {
@ -272,6 +272,8 @@
"on": "Live Streaming", "on": "Live Streaming",
"off": "Live Streaming Stopped", "off": "Live Streaming Stopped",
"unavailable": "The live streaming service is currently unavailable. Please try again later.", "unavailable": "The live streaming service is currently unavailable. Please try again later.",
"failedToStart": "Live streaming failed to start" "failedToStart": "Live streaming failed to start",
"buttonTooltip": "Start / stop live stream",
"streamIdRequired": "Please fill in the stream id in order to launch the live streaming."
} }
} }

View File

@ -32,27 +32,73 @@ function _isRecordingButtonEnabled() {
* @returns {Promise} * @returns {Promise}
*/ */
function _requestLiveStreamId() { function _requestLiveStreamId() {
let msg = APP.translation.generateTranslationHTML("dialog.liveStreaming"); const msg = APP.translation.generateTranslationHTML("dialog.liveStreaming");
let token = APP.translation.translateString("dialog.streamKey"); const token = APP.translation.translateString("dialog.streamKey");
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");
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
APP.UI.messageHandler.openTwoButtonDialog( let dialog = APP.UI.messageHandler.openDialogWithStates({
null, null, null, state0: {
html:
`<h2>${msg}</h2> `<h2>${msg}</h2>
<input name="streamId" type="text" <input name="streamId" type="text"
data-i18n="[placeholder]dialog.streamKey" data-i18n="[placeholder]dialog.streamKey"
placeholder="${token}" autofocus>`, placeholder="${token}" autofocus>`,
false, "dialog.startLiveStreaming", persistent: false,
function (e, v, m, f) { buttons: [
if (v && f.streamId) { {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)); resolve(UIUtil.escapeHtml(f.streamId));
dialog.close();
return;
}
else {
dialog.goToState('state1');
return false;
}
} else { } else {
reject(); reject();
dialog.close();
return false;
}
} }
}, },
null,
function () { }, state1: {
':input:first' html: `<h2>${msg}</h2> ${streamIdRequired}`,
); persistent: false,
buttons: [
{title: cancelButton, value: false},
{title: backButton, value: true}
],
focus: ':input:first',
defaultButton: 1,
submit: function (e, v, m, f) {
e.preventDefault();
if (v === 0) {
reject();
dialog.close();
} else {
dialog.goToState('state0');
}
}
}
});
}); });
} }
@ -129,12 +175,22 @@ function moveToCorner(selector, move) {
selector.removeClass(moveToCornerClass); selector.removeClass(moveToCornerClass);
} }
var Status = {
ON: "on",
OFF: "off",
AVAILABLE: "available",
UNAVAILABLE: "unavailable",
PENDING: "pending"
}
var Recording = { var Recording = {
/** /**
* Initializes the recording UI. * Initializes the recording UI.
*/ */
init (emitter, recordingType) { init (emitter, recordingType) {
this.eventEmitter = emitter; this.eventEmitter = emitter;
// Use recorder states directly from the library.
this.currentState = Status.UNAVAILABLE;
this.initRecordingButton(recordingType); this.initRecordingButton(recordingType);
}, },
@ -148,6 +204,7 @@ var Recording = {
this.recordingOffKey = "liveStreaming.off"; this.recordingOffKey = "liveStreaming.off";
this.recordingPendingKey = "liveStreaming.pending"; this.recordingPendingKey = "liveStreaming.pending";
this.failedToStartKey = "liveStreaming.failedToStart"; this.failedToStartKey = "liveStreaming.failedToStart";
this.recordingButtonTooltip = "liveStreaming.buttonTooltip";
} }
else { else {
this.baseClass = "icon-recEnable"; this.baseClass = "icon-recEnable";
@ -155,21 +212,25 @@ var Recording = {
this.recordingOffKey = "recording.off"; this.recordingOffKey = "recording.off";
this.recordingPendingKey = "recording.pending"; this.recordingPendingKey = "recording.pending";
this.failedToStartKey = "recording.failedToStart"; this.failedToStartKey = "recording.failedToStart";
this.recordingButtonTooltip = "recording.buttonTooltip";
} }
selector.addClass(this.baseClass); selector.addClass(this.baseClass);
selector.attr("data-i18n", "[content]" + this.recordingButtonTooltip);
selector.attr("content",
APP.translation.translateString(this.recordingButtonTooltip));
var self = this; var self = this;
selector.click(function () { selector.click(function () {
console.log("BUTTON CLICKED", self.currentState);
switch (self.currentState) { switch (self.currentState) {
case "on": { case Status.ON:
case Status.PENDING: {
_showStopRecordingPrompt(recordingType).then(() => _showStopRecordingPrompt(recordingType).then(() =>
self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED)); self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED));
}
break; break;
case "available": }
case "off": { case Status.AVAILABLE:
case Status.OFF: {
if (recordingType === 'jibri') if (recordingType === 'jibri')
_requestLiveStreamId().then((streamId) => { _requestLiveStreamId().then((streamId) => {
self.eventEmitter.emit( UIEvents.RECORDING_TOGGLED, self.eventEmitter.emit( UIEvents.RECORDING_TOGGLED,
@ -187,8 +248,8 @@ var Recording = {
{token: token}); {token: token});
}); });
} }
}
break; break;
}
default: { default: {
APP.UI.messageHandler.openMessageDialog( APP.UI.messageHandler.openMessageDialog(
"dialog.liveStreaming", "dialog.liveStreaming",
@ -222,7 +283,7 @@ var Recording = {
let labelSelector = $('#recordingLabel'); let labelSelector = $('#recordingLabel');
// TODO: handle recording state=available // TODO: handle recording state=available
if (recordingState === 'on') { if (recordingState === Status.ON) {
buttonSelector.removeClass(this.baseClass); buttonSelector.removeClass(this.baseClass);
buttonSelector.addClass(this.baseClass + " active"); buttonSelector.addClass(this.baseClass + " active");
@ -231,13 +292,13 @@ var Recording = {
moveToCorner(labelSelector, true, 3000); moveToCorner(labelSelector, true, 3000);
labelSelector labelSelector
.text(APP.translation.translateString(this.recordingOnKey)); .text(APP.translation.translateString(this.recordingOnKey));
} else if (recordingState === 'off' } else if (recordingState === Status.OFF
|| recordingState === 'unavailable') { || recordingState === Status.UNAVAILABLE) {
// We don't want to do any changes if this is // We don't want to do any changes if this is
// an availability change. // an availability change.
if (this.currentState === "available" if (this.currentState === Status.AVAILABLE
|| this.currentState === "unavailable") || this.currentState === Status.UNAVAILABLE)
return; return;
buttonSelector.removeClass(this.baseClass + " active"); buttonSelector.removeClass(this.baseClass + " active");
@ -245,7 +306,7 @@ var Recording = {
moveToCorner(labelSelector, false); moveToCorner(labelSelector, false);
let messageKey; let messageKey;
if (this.currentState === "pending") if (this.currentState === Status.PENDING)
messageKey = this.failedToStartKey; messageKey = this.failedToStartKey;
else else
messageKey = this.recordingOffKey; messageKey = this.recordingOffKey;
@ -257,7 +318,7 @@ var Recording = {
$('#recordingLabel').css({display: "none"}); $('#recordingLabel').css({display: "none"});
}, 5000); }, 5000);
} }
else if (recordingState === 'pending') { else if (recordingState === Status.PENDING) {
buttonSelector.removeClass(this.baseClass + " active"); buttonSelector.removeClass(this.baseClass + " active");
buttonSelector.addClass(this.baseClass); buttonSelector.addClass(this.baseClass);