2017-04-21 21:14:14 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-05-15 18:55:08 +00:00
|
|
|
import { toggleAudioOnly } from '../../base/conference';
|
|
|
|
import { translate } from '../../base/i18n';
|
2017-04-21 21:14:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* React {@code Component} responsible for displaying a label that indicates
|
|
|
|
* the displayed video state of the current conference. {@code AudioOnlyLabel}
|
|
|
|
* will display when the conference is in audio only mode. {@code HDVideoLabel}
|
|
|
|
* will display if not in audio only mode and a high-definition large video is
|
|
|
|
* being displayed.
|
|
|
|
*/
|
|
|
|
export class VideoStatusLabel extends Component {
|
|
|
|
/**
|
|
|
|
* {@code VideoStatusLabel}'s property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
|
|
|
/**
|
|
|
|
* Whether or not the conference is in audio only mode.
|
|
|
|
*/
|
|
|
|
_audioOnly: React.PropTypes.bool,
|
|
|
|
|
2017-05-15 18:55:08 +00:00
|
|
|
/**
|
|
|
|
* Whether or not a connection to a conference has been established.
|
|
|
|
*/
|
|
|
|
_conferenceStarted: React.PropTypes.bool,
|
|
|
|
|
2017-04-21 21:14:14 +00:00
|
|
|
/**
|
|
|
|
* Whether or not a high-definition large video is displayed.
|
|
|
|
*/
|
2017-05-15 18:55:08 +00:00
|
|
|
_largeVideoHD: React.PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to request toggling of audio only mode.
|
|
|
|
*/
|
|
|
|
dispatch: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: React.PropTypes.func
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new {@code VideoStatusLabel} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Bind event handler so it is only bound once for every instance.
|
|
|
|
this._toggleAudioOnly = this._toggleAudioOnly.bind(this);
|
2017-04-21 21:14:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
2017-05-15 18:55:08 +00:00
|
|
|
* @returns {ReactElement}
|
2017-04-21 21:14:14 +00:00
|
|
|
*/
|
|
|
|
render() {
|
2017-05-15 18:55:08 +00:00
|
|
|
const { _audioOnly, _conferenceStarted, _largeVideoHD, t } = this.props;
|
|
|
|
|
2017-05-18 23:09:22 +00:00
|
|
|
// FIXME The _conferenceStarted check is used to be defensive against
|
|
|
|
// toggling audio only mode while there is no conference and hides the
|
|
|
|
// need for error handling around audio only mode toggling.
|
|
|
|
if (!_conferenceStarted) {
|
2017-05-15 18:55:08 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let displayedLabel;
|
|
|
|
|
|
|
|
if (_audioOnly) {
|
|
|
|
displayedLabel = <i className = 'icon-visibility-off' />;
|
|
|
|
} else {
|
|
|
|
displayedLabel = _largeVideoHD
|
|
|
|
? t('videoStatus.hd') : t('videoStatus.sd');
|
2017-04-21 21:14:14 +00:00
|
|
|
}
|
|
|
|
|
2017-05-15 18:55:08 +00:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className = 'video-state-indicator moveToCorner'
|
|
|
|
id = 'videoResolutionLabel' >
|
|
|
|
{ displayedLabel }
|
|
|
|
{ this._renderVideonMenu() }
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a dropdown menu for changing video modes.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderVideonMenu() {
|
|
|
|
const { _audioOnly, t } = this.props;
|
|
|
|
const audioOnlyAttributes = _audioOnly ? { className: 'active' }
|
|
|
|
: { onClick: this._toggleAudioOnly };
|
|
|
|
const videoAttributes = _audioOnly ? { onClick: this._toggleAudioOnly }
|
|
|
|
: { className: 'active' };
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = 'video-state-indicator-menu'>
|
|
|
|
<div className = 'video-state-indicator-menu-options'>
|
|
|
|
<div { ...audioOnlyAttributes }>
|
|
|
|
<i className = 'icon-visibility' />
|
|
|
|
{ t('audioOnly.audioOnly') }
|
|
|
|
</div>
|
|
|
|
<div { ...videoAttributes }>
|
|
|
|
<i className = 'icon-camera' />
|
|
|
|
{ this.props._largeVideoHD
|
|
|
|
? t('videoStatus.hdVideo')
|
|
|
|
: t('videoStatus.sdVideo') }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches an action to toggle the state of audio only mode.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_toggleAudioOnly() {
|
|
|
|
this.props.dispatch(toggleAudioOnly());
|
2017-04-21 21:14:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code VideoStatusLabel}'s
|
|
|
|
* props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _audioOnly: boolean,
|
2017-05-15 18:55:08 +00:00
|
|
|
* _conferenceStarted: boolean,
|
|
|
|
* _largeVideoHD: (boolean|undefined)
|
2017-04-21 21:14:14 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
2017-05-15 18:55:08 +00:00
|
|
|
const {
|
|
|
|
audioOnly,
|
|
|
|
conference,
|
|
|
|
isLargeVideoHD
|
|
|
|
} = state['features/base/conference'];
|
2017-04-21 21:14:14 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
_audioOnly: audioOnly,
|
2017-05-15 18:55:08 +00:00
|
|
|
_conferenceStarted: Boolean(conference),
|
2017-04-21 21:14:14 +00:00
|
|
|
_largeVideoHD: isLargeVideoHD
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-05-15 18:55:08 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(VideoStatusLabel));
|