2019-01-05 16:49:21 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import {
|
|
|
|
createRemoteVideoMenuButtonEvent,
|
|
|
|
sendAnalytics
|
|
|
|
} from '../../analytics';
|
|
|
|
import { openDialog } from '../../base/dialog';
|
2019-08-30 16:39:06 +00:00
|
|
|
import { IconMicDisabled } from '../../base/icons';
|
2019-01-05 16:49:21 +00:00
|
|
|
import { MEDIA_TYPE } from '../../base/media';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2019-01-05 16:49:21 +00:00
|
|
|
import { isRemoteTrackMuted } from '../../base/tracks';
|
|
|
|
|
|
|
|
import { MuteRemoteParticipantDialog } from '.';
|
|
|
|
|
|
|
|
export type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Boolean to indicate if the audio track of the participant is muted or
|
|
|
|
* not.
|
|
|
|
*/
|
|
|
|
_audioTrackMuted: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the participant object that this button is supposed to
|
|
|
|
* mute/unmute.
|
|
|
|
*/
|
|
|
|
participantID: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The function to be used to translate i18n labels.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstract remote video menu button which mutes the remote participant.
|
|
|
|
*/
|
|
|
|
export default class AbstractMuteButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.remoteMute';
|
2019-08-30 16:39:06 +00:00
|
|
|
icon = IconMicDisabled;
|
2019-01-05 16:49:21 +00:00
|
|
|
label = 'videothumbnail.domute';
|
|
|
|
toggledLabel = 'videothumbnail.muted';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and mutes the participant.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
const { dispatch, participantID } = this.props;
|
|
|
|
|
|
|
|
sendAnalytics(createRemoteVideoMenuButtonEvent(
|
|
|
|
'mute.button',
|
|
|
|
{
|
|
|
|
'participant_id': participantID
|
|
|
|
}));
|
|
|
|
|
|
|
|
dispatch(openDialog(MuteRemoteParticipantDialog, { participantID }));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the item disabled if the participant is muted.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_isDisabled() {
|
|
|
|
return this.props._audioTrackMuted;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the item toggled if the participant is muted.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._audioTrackMuted;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @param {Object} ownProps - Properties of component.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _audioTrackMuted: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function _mapStateToProps(state: Object, ownProps: Props) {
|
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
|
|
|
|
return {
|
|
|
|
_audioTrackMuted: isRemoteTrackMuted(
|
|
|
|
tracks, MEDIA_TYPE.AUDIO, ownProps.participantID)
|
|
|
|
};
|
|
|
|
}
|