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.

AbstractVideoMuteButton.js 1.6KB

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