Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AbstractMuteButton.ts 2.5KB

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