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

ToggleCameraButton.js 2.0KB

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