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

ToggleCameraButton.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /**
  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 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, any> {
  29. accessibilityLabel = 'toolbar.accessibilityLabel.toggleCamera';
  30. icon = IconCameraRefresh;
  31. label = 'toolbar.toggleCamera';
  32. /**
  33. * Handles clicking/pressing the button.
  34. *
  35. * @returns {void}
  36. */
  37. _handleClick() {
  38. const { dispatch } = this.props;
  39. dispatch(toggleCamera());
  40. }
  41. /**
  42. * Whether this button is disabled or not.
  43. *
  44. * @returns {boolean}
  45. */
  46. _isDisabled() {
  47. return this.props._audioOnly || this.props._videoMuted;
  48. }
  49. }
  50. /**
  51. * Maps (parts of) the redux state to the associated props for the
  52. * {@code ToggleCameraButton} component.
  53. *
  54. * @param {Object} state - The Redux state.
  55. * @returns {Props}
  56. */
  57. function mapStateToProps(state): Object {
  58. const { enabled: audioOnly } = state['features/base/audio-only'];
  59. const tracks = state['features/base/tracks'];
  60. return {
  61. _audioOnly: Boolean(audioOnly),
  62. _videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO),
  63. visible: isToggleCameraEnabled(state)
  64. };
  65. }
  66. export default translate(connect(mapStateToProps)(ToggleCameraButton));