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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. this._setAudioMuted(!this._isAudioMuted());
  22. }
  23. /**
  24. * Helper function to be implemented by subclasses, which must return a
  25. * boolean value indicating if audio is muted or not.
  26. *
  27. * @protected
  28. * @returns {boolean}
  29. */
  30. _isAudioMuted() {
  31. // To be implemented by subclass.
  32. }
  33. /**
  34. * Indicates whether this button is in toggled state or not.
  35. *
  36. * @override
  37. * @protected
  38. * @returns {boolean}
  39. */
  40. _isToggled() {
  41. return this._isAudioMuted();
  42. }
  43. /**
  44. * Helper function to perform the actual setting of the audio mute / unmute
  45. * action.
  46. *
  47. * @param {boolean} audioMuted - Whether audio should be muted or not.
  48. * @protected
  49. * @returns {void}
  50. */
  51. _setAudioMuted(audioMuted: boolean) { // eslint-disable-line no-unused-vars
  52. // To be implemented by subclass.
  53. }
  54. }