Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

SharedVideoButton.ts 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  3. import { translate } from '../../../base/i18n/functions';
  4. import { IconPlay } from '../../../base/icons/svg';
  5. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  6. import { toggleSharedVideo } from '../../actions.any';
  7. import { isSharingStatus } from '../../functions';
  8. interface IProps extends AbstractButtonProps {
  9. /**
  10. * Whether or not the button is disabled.
  11. */
  12. _isDisabled: boolean;
  13. /**
  14. * Whether or not the local participant is sharing a video.
  15. */
  16. _sharingVideo: boolean;
  17. }
  18. /**
  19. * Implements an {@link AbstractButton} to open the user documentation in a new window.
  20. */
  21. class SharedVideoButton extends AbstractButton<IProps> {
  22. accessibilityLabel = 'toolbar.accessibilityLabel.sharedvideo';
  23. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.stopSharedVideo';
  24. icon = IconPlay;
  25. label = 'toolbar.sharedvideo';
  26. toggledLabel = 'toolbar.stopSharedVideo';
  27. tooltip = 'toolbar.sharedvideo';
  28. toggledTooltip = 'toolbar.stopSharedVideo';
  29. /**
  30. * Handles clicking / pressing the button, and opens a new dialog.
  31. *
  32. * @private
  33. * @returns {void}
  34. */
  35. _handleClick() {
  36. this._doToggleSharedVideo();
  37. }
  38. /**
  39. * Indicates whether this button is in toggled state or not.
  40. *
  41. * @override
  42. * @protected
  43. * @returns {boolean}
  44. */
  45. _isToggled() {
  46. return this.props._sharingVideo;
  47. }
  48. /**
  49. * Indicates whether this button is disabled or not.
  50. *
  51. * @override
  52. * @protected
  53. * @returns {boolean}
  54. */
  55. _isDisabled() {
  56. return this.props._isDisabled;
  57. }
  58. /**
  59. * Dispatches an action to toggle video sharing.
  60. *
  61. * @private
  62. * @returns {void}
  63. */
  64. _doToggleSharedVideo() {
  65. this.props.dispatch(toggleSharedVideo());
  66. }
  67. }
  68. /**
  69. * Maps part of the Redux state to the props of this component.
  70. *
  71. * @param {Object} state - The Redux state.
  72. * @private
  73. * @returns {IProps}
  74. */
  75. function _mapStateToProps(state: IReduxState) {
  76. const {
  77. disabled: sharedVideoBtnDisabled,
  78. status: sharedVideoStatus
  79. } = state['features/shared-video'];
  80. return {
  81. _isDisabled: Boolean(sharedVideoBtnDisabled),
  82. _sharingVideo: isSharingStatus(sharedVideoStatus ?? '')
  83. };
  84. }
  85. export default translate(connect(_mapStateToProps)(SharedVideoButton));