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.

RemoteVideoMenuTriggerButton.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { Popover } from '../../base/popover';
  4. import {
  5. MuteButton,
  6. KickButton,
  7. RemoteControlButton,
  8. RemoteVideoMenu,
  9. VolumeSlider
  10. } from './';
  11. declare var $: Object;
  12. declare var interfaceConfig: Object;
  13. /**
  14. * React {@code Component} for displaying an icon associated with opening the
  15. * the {@code RemoteVideoMenu}.
  16. *
  17. * @extends {Component}
  18. */
  19. class RemoteVideoMenuTriggerButton extends Component {
  20. static propTypes = {
  21. /**
  22. * A value between 0 and 1 indicating the volume of the participant's
  23. * audio element.
  24. */
  25. initialVolumeValue: PropTypes.number,
  26. /**
  27. * Whether or not the participant is currently muted.
  28. */
  29. isAudioMuted: PropTypes.bool,
  30. /**
  31. * Whether or not the participant is a conference moderator.
  32. */
  33. isModerator: PropTypes.bool,
  34. /**
  35. * Callback to invoke when the popover has been displayed.
  36. */
  37. onMenuDisplay: PropTypes.func,
  38. /**
  39. * Callback to invoke choosing to start a remote control session with
  40. * the participant.
  41. */
  42. onRemoteControlToggle: PropTypes.func,
  43. /**
  44. * Callback to invoke when changing the level of the participant's
  45. * audio element.
  46. */
  47. onVolumeChange: PropTypes.func,
  48. /**
  49. * The ID for the participant on which the remote video menu will act.
  50. */
  51. participantID: PropTypes.string,
  52. /**
  53. * The current state of the participant's remote control session.
  54. */
  55. remoteControlState: PropTypes.number
  56. };
  57. /**
  58. * Initializes a new {#@code RemoteVideoMenuTriggerButton} instance.
  59. *
  60. * @param {Object} props - The read-only properties with which the new
  61. * instance is to be initialized.
  62. */
  63. constructor(props) {
  64. super(props);
  65. /**
  66. * The internal reference to topmost DOM/HTML element backing the React
  67. * {@code Component}. Accessed directly for associating an element as
  68. * the trigger for a popover.
  69. *
  70. * @private
  71. * @type {HTMLDivElement}
  72. */
  73. this._rootElement = null;
  74. // Bind event handler so it is only bound once for every instance.
  75. this._onShowRemoteMenu = this._onShowRemoteMenu.bind(this);
  76. }
  77. /**
  78. * Implements React's {@link Component#render()}.
  79. *
  80. * @inheritdoc
  81. * @returns {ReactElement}
  82. */
  83. render() {
  84. const content = this._renderRemoteVideoMenu();
  85. if (!content) {
  86. return null;
  87. }
  88. return (
  89. <Popover
  90. content = { content }
  91. onPopoverOpen = { this._onShowRemoteMenu }
  92. position = { interfaceConfig.VERTICAL_FILMSTRIP
  93. ? 'left bottom' : 'top center' }>
  94. <span
  95. className = 'popover-trigger remote-video-menu-trigger'>
  96. <i
  97. className = 'icon-thumb-menu'
  98. title = 'Remote user controls' />
  99. </span>
  100. </Popover>
  101. );
  102. }
  103. /**
  104. * Opens the {@code RemoteVideoMenu}.
  105. *
  106. * @private
  107. * @returns {void}
  108. */
  109. _onShowRemoteMenu() {
  110. this.props.onMenuDisplay();
  111. }
  112. /**
  113. * Creates a new {@code RemoteVideoMenu} with buttons for interacting with
  114. * the remote participant.
  115. *
  116. * @private
  117. * @returns {ReactElement}
  118. */
  119. _renderRemoteVideoMenu() {
  120. const {
  121. initialVolumeValue,
  122. isAudioMuted,
  123. isModerator,
  124. onRemoteControlToggle,
  125. onVolumeChange,
  126. remoteControlState,
  127. participantID
  128. } = this.props;
  129. const buttons = [];
  130. if (isModerator) {
  131. buttons.push(
  132. <MuteButton
  133. isAudioMuted = { isAudioMuted }
  134. key = 'mute'
  135. participantID = { participantID } />
  136. );
  137. buttons.push(
  138. <KickButton
  139. key = 'kick'
  140. participantID = { participantID } />
  141. );
  142. }
  143. if (remoteControlState) {
  144. buttons.push(
  145. <RemoteControlButton
  146. key = 'remote-control'
  147. onClick = { onRemoteControlToggle }
  148. participantID = { participantID }
  149. remoteControlState = { remoteControlState } />
  150. );
  151. }
  152. if (onVolumeChange && isModerator) {
  153. buttons.push(
  154. <VolumeSlider
  155. initialValue = { initialVolumeValue }
  156. key = 'volume-slider'
  157. onChange = { onVolumeChange } />
  158. );
  159. }
  160. if (buttons.length > 0) {
  161. return (
  162. <RemoteVideoMenu id = { participantID }>
  163. { buttons }
  164. </RemoteVideoMenu>
  165. );
  166. }
  167. return null;
  168. }
  169. }
  170. export default RemoteVideoMenuTriggerButton;