選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

RemoteVideoMenuTriggerButton.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import AKInlineDialog 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._onRemoteMenuClose = this._onRemoteMenuClose.bind(this);
  78. this._onRemoteMenuToggle = this._onRemoteMenuToggle.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. <AKInlineDialog
  93. content = { content }
  94. isOpen = { this.state.showRemoteMenu }
  95. onClose = { this._onRemoteMenuClose }
  96. position = { interfaceConfig.VERTICAL_FILMSTRIP
  97. ? 'left middle' : 'top center' }
  98. shouldFlip = { true }>
  99. <span
  100. className = 'popover-trigger remote-video-menu-trigger'
  101. onClick = { this._onRemoteMenuToggle }>
  102. <i
  103. className = 'icon-thumb-menu'
  104. title = 'Remote user controls' />
  105. </span>
  106. </AKInlineDialog>
  107. );
  108. }
  109. /**
  110. * Closes the {@code RemoteVideoMenu}.
  111. *
  112. * @private
  113. * @returns {void}
  114. */
  115. _onRemoteMenuClose() {
  116. this.setState({ showRemoteMenu: false });
  117. }
  118. /**
  119. * Opens or closes the {@code RemoteVideoMenu}.
  120. *
  121. * @private
  122. * @returns {void}
  123. */
  124. _onRemoteMenuToggle() {
  125. const willShowRemoteMenu = !this.state.showRemoteMenu;
  126. if (willShowRemoteMenu) {
  127. this.props.onMenuDisplay();
  128. }
  129. this.setState({ showRemoteMenu: willShowRemoteMenu });
  130. }
  131. /**
  132. * Creates a new {@code RemoteVideoMenu} with buttons for interacting with
  133. * the remote participant.
  134. *
  135. * @private
  136. * @returns {ReactElement}
  137. */
  138. _renderRemoteVideoMenu() {
  139. const {
  140. initialVolumeValue,
  141. isAudioMuted,
  142. isModerator,
  143. onRemoteControlToggle,
  144. onVolumeChange,
  145. remoteControlState,
  146. participantID
  147. } = this.props;
  148. const buttons = [];
  149. if (isModerator) {
  150. buttons.push(
  151. <MuteButton
  152. isAudioMuted = { isAudioMuted }
  153. key = 'mute'
  154. onClick = { this._onRemoteMenuClose }
  155. participantID = { participantID } />
  156. );
  157. buttons.push(
  158. <KickButton
  159. key = 'kick'
  160. onClick = { this._onRemoteMenuClose }
  161. participantID = { participantID } />
  162. );
  163. }
  164. if (remoteControlState) {
  165. buttons.push(
  166. <RemoteControlButton
  167. key = 'remote-control'
  168. onClick = { onRemoteControlToggle }
  169. participantID = { participantID }
  170. remoteControlState = { remoteControlState } />
  171. );
  172. }
  173. if (onVolumeChange && isModerator) {
  174. buttons.push(
  175. <VolumeSlider
  176. initialValue = { initialVolumeValue }
  177. key = 'volume-slider'
  178. onChange = { onVolumeChange } />
  179. );
  180. }
  181. if (buttons.length > 0) {
  182. return (
  183. <RemoteVideoMenu id = { participantID }>
  184. { buttons }
  185. </RemoteVideoMenu>
  186. );
  187. }
  188. return null;
  189. }
  190. }
  191. export default RemoteVideoMenuTriggerButton;