2021-02-24 21:45:07 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import {
|
|
|
|
createRemoteVideoMenuButtonEvent,
|
|
|
|
sendAnalytics
|
|
|
|
} from '../../analytics';
|
|
|
|
import { openDialog } from '../../base/dialog';
|
2021-07-30 09:46:49 +00:00
|
|
|
import { IconVideoOff } from '../../base/icons';
|
2021-02-24 21:45:07 +00:00
|
|
|
import { MEDIA_TYPE } from '../../base/media';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
|
|
|
import { isRemoteTrackMuted } from '../../base/tracks';
|
|
|
|
|
2022-01-20 10:59:50 +00:00
|
|
|
import { MuteRemoteParticipantsVideoDialog } from './';
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
export type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Boolean to indicate if the video track of the participant is muted or
|
|
|
|
* not.
|
|
|
|
*/
|
|
|
|
_videoTrackMuted: 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 AbstractMuteVideoButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.remoteVideoMute';
|
2021-07-30 09:46:49 +00:00
|
|
|
icon = IconVideoOff;
|
2021-02-24 21:45:07 +00:00
|
|
|
label = 'videothumbnail.domuteVideo';
|
|
|
|
toggledLabel = 'videothumbnail.videoMuted';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and mutes the participant.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
const { dispatch, participantID } = this.props;
|
|
|
|
|
|
|
|
sendAnalytics(createRemoteVideoMenuButtonEvent(
|
2021-11-09 10:20:40 +00:00
|
|
|
'video.mute.button',
|
2021-02-24 21:45:07 +00:00
|
|
|
{
|
|
|
|
'participant_id': participantID
|
|
|
|
}));
|
|
|
|
|
|
|
|
dispatch(openDialog(MuteRemoteParticipantsVideoDialog, { participantID }));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the item disabled if the participant is muted.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_isDisabled() {
|
|
|
|
return this.props._videoTrackMuted;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the item toggled if the participant is muted.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._videoTrackMuted;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @param {Object} ownProps - Properties of component.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _videoTrackMuted: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function _mapStateToProps(state: Object, ownProps: Props) {
|
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
|
|
|
|
return {
|
|
|
|
_videoTrackMuted: isRemoteTrackMuted(
|
|
|
|
tracks, MEDIA_TYPE.VIDEO, ownProps.participantID)
|
|
|
|
};
|
|
|
|
}
|