您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SharedVideoButton.js 2.5KB

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