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.

MuteButton.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../base/i18n';
  5. import JitsiMeetJS from '../../base/lib-jitsi-meet';
  6. import { muteRemoteParticipant } from '../../base/participants';
  7. import RemoteVideoMenuButton from './RemoteVideoMenuButton';
  8. /**
  9. * Implements a React {@link Component} which displays a button for audio muting
  10. * a participant in the conference.
  11. *
  12. * @extends Component
  13. */
  14. class MuteButton extends Component {
  15. /**
  16. * {@code MuteButton} component's property types.
  17. *
  18. * @static
  19. */
  20. static propTypes = {
  21. /**
  22. * Invoked to send a request for muting the participant with the passed
  23. * in participantID.
  24. */
  25. dispatch: PropTypes.func,
  26. /**
  27. * Whether or not the participant is currently audio muted.
  28. */
  29. isAudioMuted: PropTypes.bool,
  30. /**
  31. * Callback to invoke when {@code MuteButton} is clicked.
  32. */
  33. onClick: PropTypes.func,
  34. /**
  35. * The ID of the participant linked to the onClick callback.
  36. */
  37. participantID: PropTypes.string,
  38. /**
  39. * Invoked to obtain translated strings.
  40. */
  41. t: PropTypes.func
  42. };
  43. /**
  44. * Initializes a new {@code MuteButton} instance.
  45. *
  46. * @param {Object} props - The read-only React Component props with which
  47. * the new instance is to be initialized.
  48. */
  49. constructor(props) {
  50. super(props);
  51. // Bind event handlers so they are only bound once for every instance.
  52. this._onClick = this._onClick.bind(this);
  53. }
  54. /**
  55. * Implements React's {@link Component#render()}.
  56. *
  57. * @inheritdoc
  58. * @returns {ReactElement}
  59. */
  60. render() {
  61. const { isAudioMuted, participantID, t } = this.props;
  62. const muteConfig = isAudioMuted ? {
  63. translationKey: 'videothumbnail.muted',
  64. muteClassName: 'mutelink disabled'
  65. } : {
  66. translationKey: 'videothumbnail.domute',
  67. muteClassName: 'mutelink'
  68. };
  69. return (
  70. <RemoteVideoMenuButton
  71. buttonText = { t(muteConfig.translationKey) }
  72. displayClass = { muteConfig.muteClassName }
  73. iconClass = 'icon-mic-disabled'
  74. id = { `mutelink_${participantID}` }
  75. onClick = { this._onClick } />
  76. );
  77. }
  78. /**
  79. * Dispatches a request to mute the participant with the passed in
  80. * participantID.
  81. *
  82. * @private
  83. * @returns {void}
  84. */
  85. _onClick() {
  86. const { dispatch, onClick, participantID } = this.props;
  87. JitsiMeetJS.analytics.sendEvent(
  88. 'remotevideomenu.mute',
  89. {
  90. value: 1,
  91. label: participantID
  92. }
  93. );
  94. dispatch(muteRemoteParticipant(participantID));
  95. if (onClick) {
  96. onClick();
  97. }
  98. }
  99. }
  100. export default translate(connect()(MuteButton));