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.

ShareAudioButton.ts 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  3. import { translate } from '../../../base/i18n/functions';
  4. import { IconVolumeOff, IconVolumeUp } from '../../../base/icons/svg';
  5. import JitsiMeetJS from '../../../base/lib-jitsi-meet';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  7. import { setOverflowMenuVisible } from '../../../toolbox/actions.web';
  8. import { startAudioScreenShareFlow } from '../../actions.web';
  9. import { isAudioOnlySharing, isScreenAudioSupported } from '../../functions';
  10. interface IProps extends AbstractButtonProps {
  11. /**
  12. * Whether or not the local participant is audio only screen sharing.
  13. */
  14. _isAudioOnlySharing: boolean;
  15. }
  16. /**
  17. * Component that renders a toolbar button for toggling audio only screen share.
  18. */
  19. class ShareAudioButton extends AbstractButton<IProps> {
  20. accessibilityLabel = 'toolbar.accessibilityLabel.shareaudio';
  21. icon = IconVolumeUp;
  22. label = 'toolbar.shareaudio';
  23. tooltip = 'toolbar.shareaudio';
  24. toggledIcon = IconVolumeOff;
  25. toggledLabel = 'toolbar.stopAudioSharing';
  26. /**
  27. * Handles clicking / pressing the button, and opens a new dialog.
  28. *
  29. * @private
  30. * @returns {void}
  31. */
  32. _handleClick() {
  33. const { dispatch } = this.props;
  34. dispatch(startAudioScreenShareFlow());
  35. dispatch(setOverflowMenuVisible(false));
  36. }
  37. /**
  38. * Indicates whether this button is in toggled state or not.
  39. *
  40. * @override
  41. * @protected
  42. * @returns {boolean}
  43. */
  44. _isToggled() {
  45. return this.props._isAudioOnlySharing;
  46. }
  47. }
  48. /**
  49. * Maps part of the Redux state to the props of this component.
  50. *
  51. * @param {Object} state - The Redux state.
  52. * @private
  53. * @returns {IProps}
  54. */
  55. function _mapStateToProps(state: IReduxState) {
  56. return {
  57. _isAudioOnlySharing: Boolean(isAudioOnlySharing(state)),
  58. visible: JitsiMeetJS.isDesktopSharingEnabled() && isScreenAudioSupported()
  59. };
  60. }
  61. export default translate(connect(_mapStateToProps)(ShareAudioButton));