Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ToggleCameraButton.js 2.0KB

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