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.

AudioMuteButton.native.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 AbstractAudioMuteButton from './AbstractAudioMuteButton';
  8. import ToolbarButton from '../ToolbarButton';
  9. /**
  10. * Component that renders a toolbar button for toggling audio mute.
  11. *
  12. * @extends AbstractAudioMuteButton
  13. */
  14. export class AudioMuteButton extends AbstractAudioMuteButton {
  15. /**
  16. * {@code AbstractAudioMuteButton} component's property types.
  17. *
  18. * @static
  19. */
  20. static propTypes = {
  21. ...AbstractAudioMuteButton.propTypes,
  22. /**
  23. * Styles to be applied to the button and the icon to show.
  24. */
  25. buttonStyles: PropTypes.object
  26. };
  27. /**
  28. * Implements React's {@link Component#render()}.
  29. *
  30. * @inheritdoc
  31. * @returns {ReactElement}
  32. */
  33. render() {
  34. const { buttonStyles } = this.props;
  35. return (
  36. <ToolbarButton
  37. iconName = { buttonStyles.iconName }
  38. iconStyle = { buttonStyles.iconStyle }
  39. onClick = { this._onToolbarToggleAudio }
  40. style = { buttonStyles.style } />
  41. );
  42. }
  43. _onToolbarToggleAudio: () => void;
  44. }
  45. /**
  46. * Maps (parts of) the Redux state to the associated props for the
  47. * {@code AudioMuteButton} component.
  48. *
  49. * @param {Object} state - The Redux state.
  50. * @private
  51. * @returns {{
  52. * _audioMuted: boolean,
  53. * }}
  54. */
  55. function _mapStateToProps(state) {
  56. const tracks = state['features/base/tracks'];
  57. return {
  58. _audioMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO)
  59. };
  60. }
  61. export default connect(_mapStateToProps)(AudioMuteButton);