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

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