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

AbstractAudioMuteButton.tsx 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { IReduxState } from '../../app/types';
  2. import { AUDIO_MUTE_BUTTON_ENABLED } from '../../base/flags/constants';
  3. import { getFeatureFlag } from '../../base/flags/functions';
  4. import { MEDIA_TYPE } from '../../base/media/constants';
  5. import { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
  6. import BaseAudioMuteButton from '../../base/toolbox/components/BaseAudioMuteButton';
  7. import { isLocalTrackMuted } from '../../base/tracks/functions';
  8. import { muteLocal } from '../../video-menu/actions';
  9. import { isAudioMuteButtonDisabled } from '../functions';
  10. /**
  11. * The type of the React {@code Component} props of {@link AbstractAudioMuteButton}.
  12. */
  13. export interface IProps extends AbstractButtonProps {
  14. /**
  15. * Whether audio is currently muted or not.
  16. */
  17. _audioMuted: boolean;
  18. /**
  19. * Whether the button is disabled.
  20. */
  21. _disabled: boolean;
  22. }
  23. /**
  24. * Component that renders a toolbar button for toggling audio mute.
  25. *
  26. * @augments BaseAudioMuteButton
  27. */
  28. export default class AbstractAudioMuteButton<P extends IProps> extends BaseAudioMuteButton<P> {
  29. accessibilityLabel = 'toolbar.accessibilityLabel.mute';
  30. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.unmute';
  31. label = 'toolbar.mute';
  32. toggledLabel = 'toolbar.unmute';
  33. tooltip = 'toolbar.mute';
  34. toggledTooltip = 'toolbar.unmute';
  35. /**
  36. * Indicates if audio is currently muted or not.
  37. *
  38. * @override
  39. * @protected
  40. * @returns {boolean}
  41. */
  42. _isAudioMuted() {
  43. return this.props._audioMuted;
  44. }
  45. /**
  46. * Changes the muted state.
  47. *
  48. * @param {boolean} audioMuted - Whether audio should be muted or not.
  49. * @protected
  50. * @returns {void}
  51. */
  52. _setAudioMuted(audioMuted: boolean) {
  53. this.props.dispatch(muteLocal(audioMuted, MEDIA_TYPE.AUDIO));
  54. }
  55. /**
  56. * Return a boolean value indicating if this button is disabled or not.
  57. *
  58. * @returns {boolean}
  59. */
  60. _isDisabled() {
  61. return this.props._disabled;
  62. }
  63. }
  64. /**
  65. * Maps (parts of) the redux state to the associated props for the
  66. * {@code AbstractAudioMuteButton} component.
  67. *
  68. * @param {Object} state - The Redux state.
  69. * @private
  70. * @returns {{
  71. * _audioMuted: boolean,
  72. * _disabled: boolean
  73. * }}
  74. */
  75. export function mapStateToProps(state: IReduxState) {
  76. const _audioMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.AUDIO);
  77. const _disabled = isAudioMuteButtonDisabled(state);
  78. const enabledFlag = getFeatureFlag(state, AUDIO_MUTE_BUTTON_ENABLED, true);
  79. return {
  80. _audioMuted,
  81. _disabled,
  82. visible: enabledFlag
  83. };
  84. }