You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractMuteButton.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // @flow
  2. import {
  3. createRemoteVideoMenuButtonEvent,
  4. sendAnalytics
  5. } from '../../analytics';
  6. import { openDialog } from '../../base/dialog';
  7. import { IconMicDisabled } from '../../base/icons';
  8. import { MEDIA_TYPE } from '../../base/media';
  9. import {
  10. AbstractButton,
  11. type AbstractButtonProps
  12. } from '../../base/toolbox';
  13. import { isRemoteTrackMuted } from '../../base/tracks';
  14. import { MuteRemoteParticipantDialog } from '.';
  15. export type Props = AbstractButtonProps & {
  16. /**
  17. * Boolean to indicate if the audio track of the participant is muted or
  18. * not.
  19. */
  20. _audioTrackMuted: boolean,
  21. /**
  22. * The redux {@code dispatch} function.
  23. */
  24. dispatch: Function,
  25. /**
  26. * The ID of the participant object that this button is supposed to
  27. * mute/unmute.
  28. */
  29. participantID: string,
  30. /**
  31. * The function to be used to translate i18n labels.
  32. */
  33. t: Function
  34. };
  35. /**
  36. * An abstract remote video menu button which mutes the remote participant.
  37. */
  38. export default class AbstractMuteButton extends AbstractButton<Props, *> {
  39. accessibilityLabel = 'toolbar.accessibilityLabel.remoteMute';
  40. icon = IconMicDisabled;
  41. label = 'videothumbnail.domute';
  42. toggledLabel = 'videothumbnail.muted';
  43. /**
  44. * Handles clicking / pressing the button, and mutes the participant.
  45. *
  46. * @private
  47. * @returns {void}
  48. */
  49. _handleClick() {
  50. const { dispatch, participantID } = this.props;
  51. sendAnalytics(createRemoteVideoMenuButtonEvent(
  52. 'mute.button',
  53. {
  54. 'participant_id': participantID
  55. }));
  56. dispatch(openDialog(MuteRemoteParticipantDialog, { participantID }));
  57. }
  58. /**
  59. * Renders the item disabled if the participant is muted.
  60. *
  61. * @inheritdoc
  62. */
  63. _isDisabled() {
  64. return this.props._audioTrackMuted;
  65. }
  66. /**
  67. * Renders the item toggled if the participant is muted.
  68. *
  69. * @inheritdoc
  70. */
  71. _isToggled() {
  72. return this.props._audioTrackMuted;
  73. }
  74. }
  75. /**
  76. * Function that maps parts of Redux state tree into component props.
  77. *
  78. * @param {Object} state - Redux state.
  79. * @param {Object} ownProps - Properties of component.
  80. * @private
  81. * @returns {{
  82. * _audioTrackMuted: boolean
  83. * }}
  84. */
  85. export function _mapStateToProps(state: Object, ownProps: Props) {
  86. const tracks = state['features/base/tracks'];
  87. return {
  88. _audioTrackMuted: isRemoteTrackMuted(
  89. tracks, MEDIA_TYPE.AUDIO, ownProps.participantID)
  90. };
  91. }