選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

AbstractVideoMuteButton.tsx 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { IReduxState } from '../../app/types';
  2. import { VIDEO_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 BaseVideoMuteButton from '../../base/toolbox/components/BaseVideoMuteButton';
  7. import { isLocalTrackMuted } from '../../base/tracks/functions';
  8. import { handleToggleVideoMuted } from '../actions.any';
  9. import { isVideoMuteButtonDisabled } from '../functions';
  10. /**
  11. * The type of the React {@code Component} props of {@link AbstractVideoMuteButton}.
  12. */
  13. export interface IProps extends AbstractButtonProps {
  14. /**
  15. * Whether video button is disabled or not.
  16. */
  17. _videoDisabled: boolean;
  18. /**
  19. * Whether video is currently muted or not.
  20. */
  21. _videoMuted: boolean;
  22. }
  23. /**
  24. * Component that renders a toolbar button for toggling video mute.
  25. *
  26. * @augments BaseVideoMuteButton
  27. */
  28. export default class AbstractVideoMuteButton<P extends IProps> extends BaseVideoMuteButton<P> {
  29. accessibilityLabel = 'toolbar.accessibilityLabel.videomute';
  30. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.videounmute';
  31. label = 'toolbar.videomute';
  32. toggledLabel = 'toolbar.videounmute';
  33. tooltip = 'toolbar.videomute';
  34. toggledTooltip = 'toolbar.videounmute';
  35. /**
  36. * Indicates if video is currently disabled or not.
  37. *
  38. * @override
  39. * @protected
  40. * @returns {boolean}
  41. */
  42. _isDisabled() {
  43. return this.props._videoDisabled;
  44. }
  45. /**
  46. * Indicates if video is currently muted or not.
  47. *
  48. * @override
  49. * @protected
  50. * @returns {boolean}
  51. */
  52. _isVideoMuted() {
  53. return this.props._videoMuted;
  54. }
  55. /**
  56. * Changes the muted state.
  57. *
  58. * @override
  59. * @param {boolean} videoMuted - Whether video should be muted or not.
  60. * @protected
  61. * @returns {void}
  62. */
  63. _setVideoMuted(videoMuted: boolean) {
  64. this.props.dispatch(handleToggleVideoMuted(videoMuted, true, true));
  65. }
  66. }
  67. /**
  68. * Maps (parts of) the redux state to the associated props for the
  69. * {@code VideoMuteButton} component.
  70. *
  71. * @param {Object} state - The Redux state.
  72. * @private
  73. * @returns {{
  74. * _videoMuted: boolean
  75. * }}
  76. */
  77. export function mapStateToProps(state: IReduxState) {
  78. const tracks = state['features/base/tracks'];
  79. const enabledFlag = getFeatureFlag(state, VIDEO_MUTE_BUTTON_ENABLED, true);
  80. return {
  81. _videoDisabled: isVideoMuteButtonDisabled(state),
  82. _videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO),
  83. visible: enabledFlag
  84. };
  85. }