2018-04-18 14:34:40 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-05-10 23:01:55 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { MEDIA_TYPE, toggleCameraFacingMode } from '../../../base/media';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { AbstractButton } from '../../../base/toolbox';
|
|
|
|
import type { AbstractButtonProps } from '../../../base/toolbox';
|
|
|
|
import { isLocalTrackMuted } from '../../../base/tracks';
|
2018-04-18 14:34:40 +00:00
|
|
|
|
2018-05-11 02:10:26 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link ToggleCameraButton}.
|
|
|
|
*/
|
2018-04-18 14:34:40 +00:00
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the current conference is in audio only mode or not.
|
|
|
|
*/
|
|
|
|
_audioOnly: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether video is currently muted or not.
|
|
|
|
*/
|
|
|
|
_videoMuted: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function
|
2018-05-10 23:01:55 +00:00
|
|
|
};
|
2018-04-18 14:34:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An implementation of a button for toggling the camera facing mode.
|
|
|
|
*/
|
|
|
|
class ToggleCameraButton extends AbstractButton<Props, *> {
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.toggleCamera';
|
2018-04-18 14:34:40 +00:00
|
|
|
iconName = 'icon-switch-camera';
|
2018-05-15 11:20:40 +00:00
|
|
|
label = 'toolbar.toggleCamera';
|
2018-04-18 14:34:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button.
|
|
|
|
*
|
2018-05-11 02:10:26 +00:00
|
|
|
* @override
|
|
|
|
* @protected
|
2018-04-18 14:34:40 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
this.props.dispatch(toggleCameraFacingMode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is disabled or not.
|
|
|
|
*
|
|
|
|
* @override
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-04-18 14:34:40 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isDisabled() {
|
|
|
|
return this.props._audioOnly || this.props._videoMuted;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
|
|
|
* {@code ToggleCameraButton} component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _audioOnly: boolean,
|
|
|
|
* _videoMuted: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state): Object {
|
|
|
|
const { audioOnly } = state['features/base/conference'];
|
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
|
|
|
|
return {
|
|
|
|
_audioOnly: Boolean(audioOnly),
|
|
|
|
_videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(ToggleCameraButton));
|