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.

AbstractAudioMuteButton.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // @flow
  2. import { IconMicrophoneEmpty, IconMicrophoneEmptySlash } from '../../icons';
  3. import AbstractButton from './AbstractButton';
  4. import type { Props } from './AbstractButton';
  5. /**
  6. * An abstract implementation of a button for toggling audio mute.
  7. */
  8. export default class AbstractAudioMuteButton<P: Props, S: *>
  9. extends AbstractButton<P, S> {
  10. icon = IconMicrophoneEmpty;
  11. toggledIcon = IconMicrophoneEmptySlash;
  12. /**
  13. * Handles clicking / pressing the button, and toggles the audio mute state
  14. * accordingly.
  15. *
  16. * @override
  17. * @protected
  18. * @returns {void}
  19. */
  20. _handleClick() {
  21. const { handleClick } = this.props;
  22. if (handleClick) {
  23. handleClick();
  24. return;
  25. }
  26. this._setAudioMuted(!this._isAudioMuted());
  27. }
  28. /**
  29. * Helper function to be implemented by subclasses, which must return a
  30. * boolean value indicating if audio is muted or not.
  31. *
  32. * @protected
  33. * @returns {boolean}
  34. */
  35. _isAudioMuted() {
  36. // To be implemented by subclass.
  37. }
  38. /**
  39. * Indicates whether this button is in toggled state or not.
  40. *
  41. * @override
  42. * @protected
  43. * @returns {boolean}
  44. */
  45. _isToggled() {
  46. return this._isAudioMuted();
  47. }
  48. /**
  49. * Helper function to perform the actual setting of the audio mute / unmute
  50. * action.
  51. *
  52. * @param {boolean} audioMuted - Whether audio should be muted or not.
  53. * @protected
  54. * @returns {void}
  55. */
  56. _setAudioMuted(audioMuted: boolean) { // eslint-disable-line no-unused-vars
  57. // To be implemented by subclass.
  58. }
  59. }