Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ToggleCameraButton.js 2.1KB

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