You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VideoMuteButton.native.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @flow
  2. import PropTypes from 'prop-types';
  3. import React from 'react';
  4. import { connect } from 'react-redux';
  5. import { MEDIA_TYPE } from '../../../base/media';
  6. import { isLocalTrackMuted } from '../../../base/tracks';
  7. import AbstractVideoMuteButton from './AbstractVideoMuteButton';
  8. import ToolbarButton from '../ToolbarButton';
  9. /**
  10. * Component that renders a toolbar button for toggling video mute.
  11. *
  12. * @extends AbstractVideoMuteButton
  13. */
  14. class VideoMuteButton extends AbstractVideoMuteButton {
  15. /**
  16. * {@code VideoMuteButton} component's property types.
  17. *
  18. * @static
  19. */
  20. static propTypes = {
  21. ...AbstractVideoMuteButton.propTypes,
  22. /**
  23. * Whether or not the local participant is current in audio only mode.
  24. * Video mute toggling is disabled in audio only mode.
  25. */
  26. _audioOnly: PropTypes.bool,
  27. /**
  28. * Styles to be applied to the button and the icon to show.
  29. */
  30. buttonStyles: PropTypes.object
  31. };
  32. /**
  33. * Implements React's {@link Component#render()}.
  34. *
  35. * @inheritdoc
  36. * @returns {ReactElement}
  37. */
  38. render() {
  39. const { _audioOnly, buttonStyles } = this.props;
  40. return (
  41. <ToolbarButton
  42. disabled = { _audioOnly }
  43. iconName = { buttonStyles.iconName }
  44. iconStyle = { buttonStyles.iconStyle }
  45. onClick = { this._onToolbarToggleVideo }
  46. style = { buttonStyles.style } />
  47. );
  48. }
  49. _onToolbarToggleVideo: () => void;
  50. }
  51. /**
  52. * Maps (parts of) the Redux state to the associated props for the
  53. * {@code VideoMuteButton} component.
  54. *
  55. * @param {Object} state - The Redux state.
  56. * @private
  57. * @returns {{
  58. * _audioOnly: boolean,
  59. * _videoMuted: boolean
  60. * }}
  61. */
  62. function _mapStateToProps(state) {
  63. const conference = state['features/base/conference'];
  64. const tracks = state['features/base/tracks'];
  65. return {
  66. _audioOnly: Boolean(conference.audioOnly),
  67. _videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO)
  68. };
  69. }
  70. export default connect(_mapStateToProps)(VideoMuteButton);