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

Conference.js 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. // @flow
  2. import _ from 'lodash';
  3. import React from 'react';
  4. import VideoLayout from '../../../../../modules/UI/videolayout/VideoLayout';
  5. import { getConferenceNameForTitle } from '../../../base/conference';
  6. import { connect, disconnect } from '../../../base/connection';
  7. import { translate } from '../../../base/i18n';
  8. import { connect as reactReduxConnect } from '../../../base/redux';
  9. import { Chat } from '../../../chat';
  10. import { Filmstrip } from '../../../filmstrip';
  11. import { CalleeInfoContainer } from '../../../invite';
  12. import { LargeVideo } from '../../../large-video';
  13. import { KnockingParticipantList, LobbyScreen } from '../../../lobby';
  14. import { Prejoin, isPrejoinPageVisible } from '../../../prejoin';
  15. import {
  16. Toolbox,
  17. fullScreenChanged,
  18. setToolboxAlwaysVisible,
  19. showToolbox
  20. } from '../../../toolbox';
  21. import { LAYOUTS, getCurrentLayout } from '../../../video-layout';
  22. import { maybeShowSuboptimalExperienceNotification } from '../../functions';
  23. import {
  24. AbstractConference,
  25. abstractMapStateToProps
  26. } from '../AbstractConference';
  27. import type { AbstractProps } from '../AbstractConference';
  28. import Labels from './Labels';
  29. import { default as Notice } from './Notice';
  30. declare var APP: Object;
  31. declare var config: Object;
  32. declare var interfaceConfig: Object;
  33. /**
  34. * DOM events for when full screen mode has changed. Different browsers need
  35. * different vendor prefixes.
  36. *
  37. * @private
  38. * @type {Array<string>}
  39. */
  40. const FULL_SCREEN_EVENTS = [
  41. 'webkitfullscreenchange',
  42. 'mozfullscreenchange',
  43. 'fullscreenchange'
  44. ];
  45. /**
  46. * The CSS class to apply to the root element of the conference so CSS can
  47. * modify the app layout.
  48. *
  49. * @private
  50. * @type {Object}
  51. */
  52. const LAYOUT_CLASSNAMES = {
  53. [LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW]: 'horizontal-filmstrip',
  54. [LAYOUTS.TILE_VIEW]: 'tile-view',
  55. [LAYOUTS.VERTICAL_FILMSTRIP_VIEW]: 'vertical-filmstrip'
  56. };
  57. /**
  58. * The type of the React {@code Component} props of {@link Conference}.
  59. */
  60. type Props = AbstractProps & {
  61. /**
  62. * Whether the local participant is recording the conference.
  63. */
  64. _iAmRecorder: boolean,
  65. /**
  66. * Returns true if the 'lobby screen' is visible.
  67. */
  68. _isLobbyScreenVisible: boolean,
  69. /**
  70. * The CSS class to apply to the root of {@link Conference} to modify the
  71. * application layout.
  72. */
  73. _layoutClassName: string,
  74. /**
  75. * Name for this conference room.
  76. */
  77. _roomName: string,
  78. /**
  79. * If prejoin page is visible or not.
  80. */
  81. _showPrejoin: boolean,
  82. dispatch: Function,
  83. t: Function
  84. }
  85. /**
  86. * The conference page of the Web application.
  87. */
  88. class Conference extends AbstractConference<Props, *> {
  89. _onFullScreenChange: Function;
  90. _onShowToolbar: Function;
  91. _originalOnShowToolbar: Function;
  92. /**
  93. * Initializes a new Conference instance.
  94. *
  95. * @param {Object} props - The read-only properties with which the new
  96. * instance is to be initialized.
  97. */
  98. constructor(props) {
  99. super(props);
  100. // Throttle and bind this component's mousemove handler to prevent it
  101. // from firing too often.
  102. this._originalOnShowToolbar = this._onShowToolbar;
  103. this._onShowToolbar = _.throttle(
  104. () => this._originalOnShowToolbar(),
  105. 100,
  106. {
  107. leading: true,
  108. trailing: false
  109. });
  110. // Bind event handler so it is only bound once for every instance.
  111. this._onFullScreenChange = this._onFullScreenChange.bind(this);
  112. }
  113. /**
  114. * Start the connection and get the UI ready for the conference.
  115. *
  116. * @inheritdoc
  117. */
  118. componentDidMount() {
  119. document.title = `${this.props._roomName} | ${interfaceConfig.APP_NAME}`;
  120. this._start();
  121. }
  122. /**
  123. * Calls into legacy UI to update the application layout, if necessary.
  124. *
  125. * @inheritdoc
  126. * returns {void}
  127. */
  128. componentDidUpdate(prevProps) {
  129. if (this.props._shouldDisplayTileView
  130. === prevProps._shouldDisplayTileView) {
  131. return;
  132. }
  133. // TODO: For now VideoLayout is being called as LargeVideo and Filmstrip
  134. // sizing logic is still handled outside of React. Once all components
  135. // are in react they should calculate size on their own as much as
  136. // possible and pass down sizings.
  137. VideoLayout.refreshLayout();
  138. }
  139. /**
  140. * Disconnect from the conference when component will be
  141. * unmounted.
  142. *
  143. * @inheritdoc
  144. */
  145. componentWillUnmount() {
  146. APP.UI.unbindEvents();
  147. FULL_SCREEN_EVENTS.forEach(name =>
  148. document.removeEventListener(name, this._onFullScreenChange));
  149. APP.conference.isJoined() && this.props.dispatch(disconnect());
  150. }
  151. /**
  152. * Implements React's {@link Component#render()}.
  153. *
  154. * @inheritdoc
  155. * @returns {ReactElement}
  156. */
  157. render() {
  158. const {
  159. // XXX The character casing of the name filmStripOnly utilized by
  160. // interfaceConfig is obsolete but legacy support is required.
  161. filmStripOnly: filmstripOnly
  162. } = interfaceConfig;
  163. const {
  164. _iAmRecorder,
  165. _isLobbyScreenVisible,
  166. _layoutClassName,
  167. _showPrejoin
  168. } = this.props;
  169. const hideLabels = filmstripOnly || _iAmRecorder;
  170. return (
  171. <div
  172. className = { _layoutClassName }
  173. id = 'videoconference_page'
  174. onMouseMove = { this._onShowToolbar }>
  175. <Notice />
  176. <div id = 'videospace'>
  177. <LargeVideo />
  178. <KnockingParticipantList />
  179. <Filmstrip filmstripOnly = { filmstripOnly } />
  180. { hideLabels || <Labels /> }
  181. </div>
  182. { filmstripOnly || _showPrejoin || _isLobbyScreenVisible || <Toolbox /> }
  183. { filmstripOnly || <Chat /> }
  184. { this.renderNotificationsContainer() }
  185. <CalleeInfoContainer />
  186. { !filmstripOnly && _showPrejoin && <Prejoin />}
  187. </div>
  188. );
  189. }
  190. /**
  191. * Updates the Redux state when full screen mode has been enabled or
  192. * disabled.
  193. *
  194. * @private
  195. * @returns {void}
  196. */
  197. _onFullScreenChange() {
  198. this.props.dispatch(fullScreenChanged(APP.UI.isFullScreen()));
  199. }
  200. /**
  201. * Displays the toolbar.
  202. *
  203. * @private
  204. * @returns {void}
  205. */
  206. _onShowToolbar() {
  207. this.props.dispatch(showToolbox());
  208. }
  209. /**
  210. * Until we don't rewrite UI using react components
  211. * we use UI.start from old app. Also method translates
  212. * component right after it has been mounted.
  213. *
  214. * @inheritdoc
  215. */
  216. _start() {
  217. APP.UI.start();
  218. APP.UI.registerListeners();
  219. APP.UI.bindEvents();
  220. FULL_SCREEN_EVENTS.forEach(name =>
  221. document.addEventListener(name, this._onFullScreenChange));
  222. const { dispatch, t } = this.props;
  223. dispatch(connect());
  224. maybeShowSuboptimalExperienceNotification(dispatch, t);
  225. interfaceConfig.filmStripOnly
  226. && dispatch(setToolboxAlwaysVisible(true));
  227. }
  228. }
  229. /**
  230. * Maps (parts of) the Redux state to the associated props for the
  231. * {@code Conference} component.
  232. *
  233. * @param {Object} state - The Redux state.
  234. * @private
  235. * @returns {Props}
  236. */
  237. function _mapStateToProps(state) {
  238. return {
  239. ...abstractMapStateToProps(state),
  240. _iAmRecorder: state['features/base/config'].iAmRecorder,
  241. _isLobbyScreenVisible: state['features/base/dialog']?.component === LobbyScreen,
  242. _layoutClassName: LAYOUT_CLASSNAMES[getCurrentLayout(state)],
  243. _roomName: getConferenceNameForTitle(state),
  244. _showPrejoin: isPrejoinPageVisible(state)
  245. };
  246. }
  247. export default reactReduxConnect(_mapStateToProps)(translate(Conference));