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

ToggleCameraButton.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import { translate } from '../../../../base/i18n';
  4. import { MEDIA_TYPE, toggleCameraFacingMode } from '../../../../base/media';
  5. import { isLocalTrackMuted } from '../../../../base/tracks';
  6. import AbstractButton from '../AbstractButton';
  7. import type { Props as AbstractButtonProps } from '../AbstractButton';
  8. type Props = AbstractButtonProps & {
  9. /**
  10. * Whether the current conference is in audio only mode or not.
  11. */
  12. _audioOnly: boolean,
  13. /**
  14. * Whether video is currently muted or not.
  15. */
  16. _videoMuted: boolean,
  17. /**
  18. * The redux {@code dispatch} function.
  19. */
  20. dispatch: Function
  21. }
  22. /**
  23. * An implementation of a button for toggling the camera facing mode.
  24. */
  25. class ToggleCameraButton extends AbstractButton<Props, *> {
  26. accessibilityLabel = 'Share room';
  27. iconName = 'icon-switch-camera';
  28. label = 'toolbar.switchCamera';
  29. /**
  30. * Handles clicking / pressing the button.
  31. *
  32. * @private
  33. * @returns {void}
  34. */
  35. _handleClick() {
  36. this.props.dispatch(toggleCameraFacingMode());
  37. }
  38. /**
  39. * Indicates whether this button is disabled or not.
  40. *
  41. * @override
  42. * @private
  43. * @returns {boolean}
  44. */
  45. _isDisabled() {
  46. return this.props._audioOnly || this.props._videoMuted;
  47. }
  48. }
  49. /**
  50. * Maps (parts of) the redux state to the associated props for the
  51. * {@code ToggleCameraButton} component.
  52. *
  53. * @param {Object} state - The Redux state.
  54. * @private
  55. * @returns {{
  56. * _audioOnly: boolean,
  57. * _videoMuted: boolean
  58. * }}
  59. */
  60. function _mapStateToProps(state): Object {
  61. const { audioOnly } = state['features/base/conference'];
  62. const tracks = state['features/base/tracks'];
  63. return {
  64. _audioOnly: Boolean(audioOnly),
  65. _videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO)
  66. };
  67. }
  68. export default translate(connect(_mapStateToProps)(ToggleCameraButton));