Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ToggleCameraButton.ts 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  3. import { translate } from '../../../base/i18n/functions';
  4. import { IconCameraRefresh } from '../../../base/icons/svg';
  5. import { toggleCameraFacingMode } from '../../../base/media/actions';
  6. import { MEDIA_TYPE } from '../../../base/media/constants';
  7. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  8. import { isLocalTrackMuted } from '../../../base/tracks/functions.native';
  9. /**
  10. * The type of the React {@code Component} props of {@link ToggleCameraButton}.
  11. */
  12. interface IProps extends 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. /**
  23. * An implementation of a button for toggling the camera facing mode.
  24. */
  25. class ToggleCameraButton extends AbstractButton<IProps> {
  26. accessibilityLabel = 'toolbar.accessibilityLabel.toggleCamera';
  27. icon = IconCameraRefresh;
  28. label = 'toolbar.toggleCamera';
  29. /**
  30. * Handles clicking / pressing the button.
  31. *
  32. * @override
  33. * @protected
  34. * @returns {void}
  35. */
  36. _handleClick() {
  37. this.props.dispatch(toggleCameraFacingMode());
  38. }
  39. /**
  40. * Indicates whether this button is disabled or not.
  41. *
  42. * @override
  43. * @protected
  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. * @private
  56. * @returns {{
  57. * _audioOnly: boolean,
  58. * _videoMuted: boolean
  59. * }}
  60. */
  61. function _mapStateToProps(state: IReduxState) {
  62. const { enabled: audioOnly } = state['features/base/audio-only'];
  63. const tracks = state['features/base/tracks'];
  64. return {
  65. _audioOnly: Boolean(audioOnly),
  66. _videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO)
  67. };
  68. }
  69. export default translate(connect(_mapStateToProps)(ToggleCameraButton));