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

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