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

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