您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RemoteVideoMenuTriggerButton.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import { default as Popover } from '@atlaskit/inline-dialog';
  2. import React, { Component } from 'react';
  3. import {
  4. MuteButton,
  5. KickButton,
  6. RemoteControlButton,
  7. RemoteVideoMenu,
  8. VolumeSlider
  9. } from './';
  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. this.state = {
  65. showRemoteMenu: false
  66. };
  67. /**
  68. * The internal reference to topmost DOM/HTML element backing the React
  69. * {@code Component}. Accessed directly for associating an element as
  70. * the trigger for a popover.
  71. *
  72. * @private
  73. * @type {HTMLDivElement}
  74. */
  75. this._rootElement = null;
  76. // Bind event handlers so they are only bound once for every instance.
  77. this._onHideRemoteMenu = this._onHideRemoteMenu.bind(this);
  78. this._onShowRemoteMenu = this._onShowRemoteMenu.bind(this);
  79. }
  80. /**
  81. * Implements React's {@link Component#render()}.
  82. *
  83. * @inheritdoc
  84. * @returns {ReactElement}
  85. */
  86. render() {
  87. const content = this._renderRemoteVideoMenu();
  88. if (!content) {
  89. return null;
  90. }
  91. return (
  92. <div
  93. onMouseEnter = { this._onShowRemoteMenu }
  94. onMouseLeave = { this._onHideRemoteMenu }>
  95. <Popover
  96. content = { content }
  97. isOpen = { this.state.showRemoteMenu }
  98. position = { interfaceConfig.VERTICAL_FILMSTRIP
  99. ? 'left middle' : 'top center' }>
  100. <span
  101. className = 'popover-trigger remote-video-menu-trigger'>
  102. <i
  103. className = 'icon-thumb-menu'
  104. title = 'Remote user controls' />
  105. </span>
  106. </Popover>
  107. </div>
  108. );
  109. }
  110. /**
  111. * Closes the {@code RemoteVideoMenu}.
  112. *
  113. * @private
  114. * @returns {void}
  115. */
  116. _onHideRemoteMenu() {
  117. this.setState({ showRemoteMenu: false });
  118. }
  119. /**
  120. * Opens the {@code RemoteVideoMenu}.
  121. *
  122. * @private
  123. * @returns {void}
  124. */
  125. _onShowRemoteMenu() {
  126. this.props.onMenuDisplay();
  127. this.setState({ showRemoteMenu: true });
  128. }
  129. /**
  130. * Creates a new {@code RemoteVideoMenu} with buttons for interacting with
  131. * the remote participant.
  132. *
  133. * @private
  134. * @returns {ReactElement}
  135. */
  136. _renderRemoteVideoMenu() {
  137. const {
  138. initialVolumeValue,
  139. isAudioMuted,
  140. isModerator,
  141. onRemoteControlToggle,
  142. onVolumeChange,
  143. remoteControlState,
  144. participantID
  145. } = this.props;
  146. const buttons = [];
  147. if (isModerator) {
  148. buttons.push(
  149. <MuteButton
  150. isAudioMuted = { isAudioMuted }
  151. key = 'mute'
  152. onClick = { this._onHideRemoteMenu }
  153. participantID = { participantID } />
  154. );
  155. buttons.push(
  156. <KickButton
  157. key = 'kick'
  158. onClick = { this._onHideRemoteMenu }
  159. participantID = { participantID } />
  160. );
  161. }
  162. if (remoteControlState) {
  163. buttons.push(
  164. <RemoteControlButton
  165. key = 'remote-control'
  166. onClick = { onRemoteControlToggle }
  167. participantID = { participantID }
  168. remoteControlState = { remoteControlState } />
  169. );
  170. }
  171. if (onVolumeChange && isModerator) {
  172. buttons.push(
  173. <VolumeSlider
  174. initialValue = { initialVolumeValue }
  175. key = 'volume-slider'
  176. onChange = { onVolumeChange } />
  177. );
  178. }
  179. if (buttons.length > 0) {
  180. return (
  181. <div>
  182. <RemoteVideoMenu id = { participantID }>
  183. { buttons }
  184. </RemoteVideoMenu>
  185. <div
  186. className = { interfaceConfig.VERTICAL_FILMSTRIP
  187. ? 'popover-mousemove-padding-right'
  188. : 'popover-mousemove-padding-bottom' } />
  189. </div>
  190. );
  191. }
  192. return null;
  193. }
  194. }
  195. export default RemoteVideoMenuTriggerButton;