Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

AbstractMuteVideoButton.ts 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { createRemoteVideoMenuButtonEvent } from '../../analytics/AnalyticsEvents';
  2. import { sendAnalytics } from '../../analytics/functions';
  3. import { IReduxState } from '../../app/types';
  4. import { openDialog } from '../../base/dialog/actions';
  5. import { IconVideoOff } 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 { MuteRemoteParticipantsVideoDialog } from './';
  10. export interface IProps extends AbstractButtonProps {
  11. /**
  12. * Boolean to indicate if the video track of the participant is muted or
  13. * not.
  14. */
  15. _videoTrackMuted: 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 AbstractMuteVideoButton extends AbstractButton<IProps> {
  26. accessibilityLabel = 'toolbar.accessibilityLabel.remoteVideoMute';
  27. icon = IconVideoOff;
  28. label = 'videothumbnail.domuteVideo';
  29. toggledLabel = 'videothumbnail.videoMuted';
  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. 'video.mute.button',
  40. {
  41. 'participant_id': participantID
  42. }));
  43. dispatch(openDialog(MuteRemoteParticipantsVideoDialog, { participantID }));
  44. }
  45. /**
  46. * Renders the item disabled if the participant is muted.
  47. *
  48. * @inheritdoc
  49. */
  50. _isDisabled() {
  51. return this.props._videoTrackMuted;
  52. }
  53. /**
  54. * Renders the item toggled if the participant is muted.
  55. *
  56. * @inheritdoc
  57. */
  58. _isToggled() {
  59. return this.props._videoTrackMuted;
  60. }
  61. }
  62. /**
  63. * Function that maps parts of Redux state tree into component props.
  64. *
  65. * @param {Object} state - Redux state.
  66. * @param {Object} ownProps - Properties of component.
  67. * @private
  68. * @returns {{
  69. * _videoTrackMuted: boolean
  70. * }}
  71. */
  72. export function _mapStateToProps(state: IReduxState, ownProps: any) {
  73. const tracks = state['features/base/tracks'];
  74. return {
  75. _videoTrackMuted: isRemoteTrackMuted(
  76. tracks, MEDIA_TYPE.VIDEO, ownProps.participantID)
  77. };
  78. }