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.

ToolboxAlwaysOnTop.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // @flow
  2. import React, { Component } from 'react';
  3. // FIXME: AlwaysOnTop imports the button directly in order to avoid bringing in
  4. // other components that use lib-jitsi-meet, which always on top does not
  5. // import.
  6. import ToolbarButton from '../toolbox/components/ToolbarButton';
  7. const { api } = window.alwaysOnTop;
  8. /**
  9. * The type of the React {@code Component} props of {@link ToolboxAlwaysOnTop}.
  10. */
  11. type Props = {
  12. /**
  13. * Whether or not microphone access is available.
  14. */
  15. audioAvailable: boolean,
  16. /**
  17. * Whether or not the user is currently audio muted.
  18. */
  19. audioMuted: boolean,
  20. /**
  21. * Additional CSS class names to add to the root of the toolbar.
  22. */
  23. className: string,
  24. /**
  25. * Callback invoked when no longer moused over the toolbar.
  26. */
  27. onMouseOut: Function,
  28. /**
  29. * Callback invoked when the mouse has moved over the toolbar.
  30. */
  31. onMouseOver: Function,
  32. /**
  33. * Whether or not camera access is available.
  34. */
  35. videoAvailable: boolean,
  36. /**
  37. * Whether or not the user is currently video muted.
  38. */
  39. videoMuted: boolean
  40. };
  41. /**
  42. * Represents the toolbar in the Always On Top window.
  43. *
  44. * @extends Component
  45. */
  46. export default class ToolboxAlwaysOnTop extends Component<Props> {
  47. /**
  48. * Initializes a new {@code ToolboxAlwaysOnTop} instance.
  49. *
  50. * @param {Props} props - The read-only properties with which the new
  51. * instance is to be initialized.
  52. */
  53. constructor(props: Props) {
  54. super(props);
  55. // Bind event handlers so they are only bound once per instance.
  56. this._onToolbarHangup = this._onToolbarHangup.bind(this);
  57. this._onToolbarToggleAudio = this._onToolbarToggleAudio.bind(this);
  58. this._onToolbarToggleVideo = this._onToolbarToggleVideo.bind(this);
  59. }
  60. /**
  61. * Implements React's {@link Component#render()}.
  62. *
  63. * @inheritdoc
  64. * @returns {ReactElement}
  65. */
  66. render() {
  67. const {
  68. audioAvailable,
  69. audioMuted,
  70. className = '',
  71. onMouseOut,
  72. onMouseOver,
  73. videoAvailable,
  74. videoMuted
  75. } = this.props;
  76. const videoMuteIcon = `${videoMuted || !videoAvailable
  77. ? 'icon-camera-disabled toggled' : 'icon-camera'} ${
  78. videoAvailable ? '' : 'disabled'}`;
  79. const audioMuteIcon = `${audioMuted || !audioAvailable
  80. ? 'icon-mic-disabled toggled' : 'icon-microphone'} ${
  81. audioAvailable ? '' : 'disabled'}`;
  82. return (
  83. <div
  84. className = { `always-on-top-toolbox ${className}` }
  85. onMouseOut = { onMouseOut }
  86. onMouseOver = { onMouseOver }>
  87. <ToolbarButton
  88. accessibilityLabel = 'Audio mute'
  89. iconName = { audioMuteIcon }
  90. onClick = { this._onToolbarToggleAudio } />
  91. <ToolbarButton
  92. accessibilityLabel = 'Hangup'
  93. iconName = 'icon-hangup'
  94. onClick = { this._onToolbarHangup } />
  95. <ToolbarButton
  96. accessibilityLabel = 'Video mute'
  97. iconName = { videoMuteIcon }
  98. onClick = { this._onToolbarToggleVideo } />
  99. </div>
  100. );
  101. }
  102. _onToolbarHangup: () => void;
  103. /**
  104. * Ends the conference call and closes the always on top window.
  105. *
  106. * @private
  107. * @returns {void}
  108. */
  109. _onToolbarHangup() {
  110. api.executeCommand('hangup');
  111. window.close();
  112. }
  113. _onToolbarToggleAudio: () => void;
  114. /**
  115. * Toggles audio mute if audio is avaiable.
  116. *
  117. * @private
  118. * @returns {void}
  119. */
  120. _onToolbarToggleAudio() {
  121. if (this.props.audioAvailable) {
  122. api.executeCommand('toggleAudio');
  123. }
  124. }
  125. _onToolbarToggleVideo: () => void;
  126. /**
  127. * Toggles video mute if video is avaiable.
  128. *
  129. * @private
  130. * @returns {void}
  131. */
  132. _onToolbarToggleVideo() {
  133. if (this.props.videoAvailable) {
  134. api.executeCommand('toggleVideo');
  135. }
  136. }
  137. }