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

RemoteVideoMenuTriggerButton.js 5.1KB

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