@ -21,7 +21,7 @@ import UIUtil from '../util/UIUtil';
import VideoLayout from '../videolayout/VideoLayout' ;
import Feedback from '../feedback/Feedback.js' ;
import { hideToolbox } from '../../../react/features/toolbox' ;
import { setToolboxEnabled } from '../../../react/features/toolbox' ;
/ * *
* The dialog for user input .
@ -35,8 +35,10 @@ let dialog = null;
* @ private
* /
function _isRecordingButtonEnabled ( ) {
return interfaceConfig . TOOLBAR _BUTTONS . indexOf ( "recording" ) !== - 1
&& config . enableRecording && APP . conference . isRecordingSupported ( ) ;
return (
interfaceConfig . TOOLBAR _BUTTONS . indexOf ( "recording" ) !== - 1
&& config . enableRecording
&& APP . conference . isRecordingSupported ( ) ) ;
}
/ * *
@ -129,7 +131,7 @@ function _requestLiveStreamId() {
* Request recording token from the user .
* @ returns { Promise }
* /
function _requestRecordingToken ( ) {
function _requestRecordingToken ( ) {
let titleKey = "dialog.recordingToken" ;
let messageString = (
` <input name="recordingToken" type="text"
@ -164,7 +166,7 @@ function _requestRecordingToken () {
* @ returns { Promise }
* @ private
* /
function _showStopRecordingPrompt ( recordingType ) {
function _showStopRecordingPrompt ( recordingType ) {
var title ;
var message ;
var buttonKey ;
@ -179,19 +181,13 @@ function _showStopRecordingPrompt (recordingType) {
buttonKey = "dialog.stopRecording" ;
}
return new Promise ( function ( resolve , reject ) {
return new Promise ( ( resolve , reject ) => {
dialog = APP . UI . messageHandler . openTwoButtonDialog ( {
titleKey : title ,
msgKey : message ,
leftButtonKey : buttonKey ,
submitFunction : function ( e , v ) {
if ( v ) {
resolve ( ) ;
} else {
reject ( ) ;
}
} ,
closeFunction : function ( ) {
submitFunction : ( e , v ) => ( v ? resolve : reject ) ( ) ,
closeFunction : ( ) => {
dialog = null ;
}
} ) ;
@ -250,35 +246,12 @@ var Recording = {
/ * *
* Initializes the recording UI .
* /
init ( emitter , recordingType ) {
this . eventEmitter = emitter ;
init ( eventEmitter , recordingType ) {
this . eventEmitter = eventEmitter ;
this . recordingType = recordingType ;
this . updateRecordingState ( APP . conference . getRecordingState ( ) ) ;
this . initRecordingButton ( recordingType ) ;
// 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 ) ;
Feedback . enableFeedback ( false ) ;
APP . store . dispatch ( hideToolbox ( ) ) ;
APP . UI . messageHandler . enableNotifications ( false ) ;
APP . UI . messageHandler . enablePopups ( false ) ;
}
} ,
/ * *
* Initialise the recording button .
* /
initRecordingButton ( recordingType ) {
let selector = $ ( '#toolbar_button_record' ) ;
let button = selector . get ( 0 ) ;
UIUtil . setTooltip ( button , 'liveStreaming.buttonTooltip' , 'right' ) ;
if ( recordingType === 'jibri' ) {
this . baseClass = "fa fa-play-circle" ;
this . recordingTitle = "dialog.liveStreaming" ;
@ -304,101 +277,44 @@ var Recording = {
this . recordingBusy = "liveStreaming.busy" ;
}
// 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 ) ;
Feedback . enableFeedback ( false ) ;
APP . store . dispatch ( setToolboxEnabled ( false ) ) ;
APP . UI . messageHandler . enableNotifications ( false ) ;
APP . UI . messageHandler . enablePopups ( false ) ;
}
} ,
/ * *
* Initialise the recording button .
* /
initRecordingButton ( ) {
const selector = $ ( '#toolbar_button_record' ) ;
UIUtil . setTooltip ( selector , 'liveStreaming.buttonTooltip' , 'right' ) ;
selector . addClass ( this . baseClass ) ;
selector . attr ( "data-i18n" , "[content]" + this . recordingButtonTooltip ) ;
APP . translation . translateElement ( selector ) ;
var self = this ;
selector . click ( function ( ) {
if ( dialog )
return ;
JitsiMeetJS . analytics . sendEvent ( 'recording.clicked' ) ;
switch ( self . currentState ) {
case Status . ON :
case Status . RETRYING :
case Status . PENDING : {
_showStopRecordingPrompt ( recordingType ) . then (
( ) => {
self . eventEmitter . emit ( UIEvents . RECORDING _TOGGLED ) ;
JitsiMeetJS . analytics . sendEvent (
'recording.stopped' ) ;
} ,
( ) => { } ) ;
break ;
}
case Status . AVAILABLE :
case Status . OFF : {
if ( recordingType === 'jibri' )
_requestLiveStreamId ( ) . then ( ( streamId ) => {
self . eventEmitter . emit ( UIEvents . RECORDING _TOGGLED ,
{ streamId : 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 ( self . predefinedToken ) {
self . eventEmitter . emit ( UIEvents . RECORDING _TOGGLED ,
{ token : self . predefinedToken } ) ;
JitsiMeetJS . analytics . sendEvent (
'recording.started' ) ;
return ;
}
_requestRecordingToken ( ) . then ( ( token ) => {
self . eventEmitter . emit ( UIEvents . RECORDING _TOGGLED ,
{ token : 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 (
self . recordingTitle ,
self . recordingBusy ,
null ,
function ( ) {
dialog = null ;
}
) ;
break ;
}
default : {
dialog = APP . UI . messageHandler . openMessageDialog (
self . recordingTitle ,
self . recordingUnavailable ,
null ,
function ( ) {
dialog = null ;
}
) ;
}
}
} ) ;
} ,
/ * *
* Shows or hides the 'recording' button .
* @ param show { true } to show the recording button , { false } to hide it
* /
showRecordingButton ( show ) {
showRecordingButton ( show ) {
let shouldShow = show && _isRecordingButtonEnabled ( ) ;
let id = 'toolbar_button_record' ;
@ -425,7 +341,7 @@ var Recording = {
* Sets the state of the recording button .
* @ param recordingState gives us the current recording state
* /
updateRecordingUI ( recordingState ) {
updateRecordingUI ( recordingState ) {
let oldState = this . currentState ;
this . currentState = recordingState ;
@ -491,7 +407,7 @@ var Recording = {
} ,
// checks whether recording is enabled and whether we have params
// to start automatically recording
checkAutoRecord ( ) {
checkAutoRecord ( ) {
if ( _isRecordingButtonEnabled && config . autoRecord ) {
this . predefinedToken = UIUtil . escapeHtml ( config . autoRecordToken ) ;
this . eventEmitter . emit ( UIEvents . RECORDING _TOGGLED ,
@ -514,6 +430,90 @@ var Recording = {
APP . translation . translateElement ( labelSelector ) ;
} ,
/ * *
* 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 ;
}
) ;
}
}
} ,
/ * *
* Sets the toggled state of the recording toolbar button .
*