Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

Conference.web.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // @flow
  2. import _ from 'lodash';
  3. import React, { Component } from 'react';
  4. import { connect as reactReduxConnect } from 'react-redux';
  5. import { connect, disconnect } from '../../base/connection';
  6. import { DialogContainer } from '../../base/dialog';
  7. import { translate } from '../../base/i18n';
  8. import { Filmstrip } from '../../filmstrip';
  9. import { CalleeInfoContainer } from '../../invite';
  10. import { LargeVideo } from '../../large-video';
  11. import { NotificationsContainer } from '../../notifications';
  12. import { SidePanel } from '../../side-panel';
  13. import {
  14. Toolbox,
  15. fullScreenChanged,
  16. setToolboxAlwaysVisible,
  17. showToolbox
  18. } from '../../toolbox';
  19. import { maybeShowSuboptimalExperienceNotification } from '../functions';
  20. declare var APP: Object;
  21. declare var interfaceConfig: Object;
  22. /**
  23. * DOM events for when full screen mode has changed. Different browsers need
  24. * different vendor prefixes.
  25. *
  26. * @private
  27. * @type {Array<string>}
  28. */
  29. const FULL_SCREEN_EVENTS = [
  30. 'webkitfullscreenchange',
  31. 'mozfullscreenchange',
  32. 'fullscreenchange'
  33. ];
  34. /**
  35. * The type of the React {@code Component} props of {@link Conference}.
  36. */
  37. type Props = {
  38. /**
  39. * Whether the local participant is recording the conference.
  40. */
  41. _iAmRecorder: boolean,
  42. dispatch: Function,
  43. t: Function
  44. }
  45. /**
  46. * The conference page of the Web application.
  47. */
  48. class Conference extends Component<Props> {
  49. _onFullScreenChange: Function;
  50. _onShowToolbar: Function;
  51. _originalOnShowToolbar: Function;
  52. /**
  53. * Initializes a new Conference instance.
  54. *
  55. * @param {Object} props - The read-only properties with which the new
  56. * instance is to be initialized.
  57. */
  58. constructor(props) {
  59. super(props);
  60. // Throttle and bind this component's mousemove handler to prevent it
  61. // from firing too often.
  62. this._originalOnShowToolbar = this._onShowToolbar;
  63. this._onShowToolbar = _.throttle(
  64. () => this._originalOnShowToolbar(),
  65. 100,
  66. {
  67. leading: true,
  68. trailing: false
  69. });
  70. // Bind event handler so it is only bound once for every instance.
  71. this._onFullScreenChange = this._onFullScreenChange.bind(this);
  72. }
  73. /**
  74. * Until we don't rewrite UI using react components
  75. * we use UI.start from old app. Also method translates
  76. * component right after it has been mounted.
  77. *
  78. * @inheritdoc
  79. */
  80. componentDidMount() {
  81. APP.UI.start();
  82. APP.UI.registerListeners();
  83. APP.UI.bindEvents();
  84. FULL_SCREEN_EVENTS.forEach(name =>
  85. document.addEventListener(name, this._onFullScreenChange));
  86. const { dispatch, t } = this.props;
  87. dispatch(connect());
  88. maybeShowSuboptimalExperienceNotification(dispatch, t);
  89. interfaceConfig.filmStripOnly
  90. && dispatch(setToolboxAlwaysVisible(true));
  91. }
  92. /**
  93. * Disconnect from the conference when component will be
  94. * unmounted.
  95. *
  96. * @inheritdoc
  97. */
  98. componentWillUnmount() {
  99. APP.UI.unregisterListeners();
  100. APP.UI.unbindEvents();
  101. FULL_SCREEN_EVENTS.forEach(name =>
  102. document.removeEventListener(name, this._onFullScreenChange));
  103. APP.conference.isJoined() && this.props.dispatch(disconnect());
  104. }
  105. /**
  106. * Implements React's {@link Component#render()}.
  107. *
  108. * @inheritdoc
  109. * @returns {ReactElement}
  110. */
  111. render() {
  112. const {
  113. VIDEO_QUALITY_LABEL_DISABLED,
  114. // XXX The character casing of the name filmStripOnly utilized by
  115. // interfaceConfig is obsolete but legacy support is required.
  116. filmStripOnly: filmstripOnly
  117. } = interfaceConfig;
  118. const hideVideoQualityLabel
  119. = filmstripOnly
  120. || VIDEO_QUALITY_LABEL_DISABLED
  121. || this.props._iAmRecorder;
  122. return (
  123. <div
  124. id = 'videoconference_page'
  125. onMouseMove = { this._onShowToolbar }>
  126. <div id = 'videospace'>
  127. <LargeVideo
  128. hideVideoQualityLabel = { hideVideoQualityLabel } />
  129. <Filmstrip filmstripOnly = { filmstripOnly } />
  130. </div>
  131. { filmstripOnly || <Toolbox /> }
  132. { filmstripOnly || <SidePanel /> }
  133. <DialogContainer />
  134. <NotificationsContainer />
  135. <CalleeInfoContainer />
  136. </div>
  137. );
  138. }
  139. /**
  140. * Updates the Redux state when full screen mode has been enabled or
  141. * disabled.
  142. *
  143. * @private
  144. * @returns {void}
  145. */
  146. _onFullScreenChange() {
  147. this.props.dispatch(fullScreenChanged(APP.UI.isFullScreen()));
  148. }
  149. /**
  150. * Displays the toolbar.
  151. *
  152. * @private
  153. * @returns {void}
  154. */
  155. _onShowToolbar() {
  156. this.props.dispatch(showToolbox());
  157. }
  158. }
  159. /**
  160. * Maps (parts of) the Redux state to the associated props for the
  161. * {@code Conference} component.
  162. *
  163. * @param {Object} state - The Redux state.
  164. * @private
  165. * @returns {{
  166. * _iAmRecorder: boolean
  167. * }}
  168. */
  169. function _mapStateToProps(state) {
  170. const { iAmRecorder } = state['features/base/config'];
  171. return {
  172. /**
  173. * Whether the local participant is recording the conference.
  174. *
  175. * @private
  176. */
  177. _iAmRecorder: iAmRecorder
  178. };
  179. }
  180. export default reactReduxConnect(_mapStateToProps)(translate(Conference));