You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LargeVideo.web.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Watermarks } from '../../base/react';
  4. import { connect } from '../../base/redux';
  5. import { setColorAlpha } from '../../base/util';
  6. import { SharedVideo } from '../../shared-video/components/web';
  7. import { Captions } from '../../subtitles/';
  8. import { setTileView } from '../../video-layout/actions';
  9. declare var interfaceConfig: Object;
  10. type Props = {
  11. /**
  12. * The alpha(opacity) of the background
  13. */
  14. _backgroundAlpha: number,
  15. /**
  16. * The user selected background color.
  17. */
  18. _customBackgroundColor: string,
  19. /**
  20. * The user selected background image url.
  21. */
  22. _customBackgroundImageUrl: string,
  23. /**
  24. * Prop that indicates whether the chat is open.
  25. */
  26. _isChatOpen: boolean,
  27. /**
  28. * Used to determine the value of the autoplay attribute of the underlying
  29. * video element.
  30. */
  31. _noAutoPlayVideo: boolean,
  32. /**
  33. * The Redux dispatch function.
  34. */
  35. dispatch: Function
  36. }
  37. /**
  38. * Implements a React {@link Component} which represents the large video (a.k.a.
  39. * the conference participant who is on the local stage) on Web/React.
  40. *
  41. * @extends Component
  42. */
  43. class LargeVideo extends Component<Props> {
  44. _tappedTimeout: ?TimeoutID
  45. /**
  46. * Constructor of the component.
  47. *
  48. * @inheritdoc
  49. */
  50. constructor(props) {
  51. super(props);
  52. this._clearTapTimeout = this._clearTapTimeout.bind(this);
  53. this._onDoubleTap = this._onDoubleTap.bind(this);
  54. }
  55. /**
  56. * Implements React's {@link Component#render()}.
  57. *
  58. * @inheritdoc
  59. * @returns {React$Element}
  60. */
  61. render() {
  62. const {
  63. _isChatOpen,
  64. _noAutoPlayVideo
  65. } = this.props;
  66. const style = this._getCustomSyles();
  67. const className = `videocontainer${_isChatOpen ? ' shift-right' : ''}`;
  68. return (
  69. <div
  70. className = { className }
  71. id = 'largeVideoContainer'
  72. style = { style }>
  73. <SharedVideo />
  74. <div id = 'etherpad' />
  75. <Watermarks />
  76. <div
  77. id = 'dominantSpeaker'
  78. onTouchEnd = { this._onDoubleTap }>
  79. <div className = 'dynamic-shadow' />
  80. <div id = 'dominantSpeakerAvatarContainer' />
  81. </div>
  82. <div id = 'remotePresenceMessage' />
  83. <span id = 'remoteConnectionMessage' />
  84. <div id = 'largeVideoElementsContainer'>
  85. <div id = 'largeVideoBackgroundContainer' />
  86. {/*
  87. * FIXME: the architecture of elements related to the large
  88. * video and the naming. The background is not part of
  89. * largeVideoWrapper because we are controlling the size of
  90. * the video through largeVideoWrapper. That's why we need
  91. * another container for the background and the
  92. * largeVideoWrapper in order to hide/show them.
  93. */}
  94. <div
  95. id = 'largeVideoWrapper'
  96. onTouchEnd = { this._onDoubleTap }
  97. role = 'figure' >
  98. <video
  99. autoPlay = { !_noAutoPlayVideo }
  100. id = 'largeVideo'
  101. muted = { true }
  102. playsInline = { true } /* for Safari on iOS to work */ />
  103. </div>
  104. </div>
  105. { interfaceConfig.DISABLE_TRANSCRIPTION_SUBTITLES
  106. || <Captions /> }
  107. </div>
  108. );
  109. }
  110. _clearTapTimeout: () => void
  111. /**
  112. * Clears the '_tappedTimout'.
  113. *
  114. * @private
  115. * @returns {void}
  116. */
  117. _clearTapTimeout() {
  118. clearTimeout(this._tappedTimeout);
  119. this._tappedTimeout = undefined;
  120. }
  121. /**
  122. * Creates the custom styles object.
  123. *
  124. * @private
  125. * @returns {Object}
  126. */
  127. _getCustomSyles() {
  128. const styles = {};
  129. const { _customBackgroundColor, _customBackgroundImageUrl } = this.props;
  130. styles.backgroundColor = _customBackgroundColor || interfaceConfig.DEFAULT_BACKGROUND;
  131. if (this.props._backgroundAlpha !== undefined) {
  132. const alphaColor = setColorAlpha(styles.backgroundColor, this.props._backgroundAlpha);
  133. styles.backgroundColor = alphaColor;
  134. }
  135. if (_customBackgroundImageUrl) {
  136. styles.backgroundImage = `url(${_customBackgroundImageUrl})`;
  137. styles.backgroundSize = 'cover';
  138. }
  139. return styles;
  140. }
  141. _onDoubleTap: () => void
  142. /**
  143. * Sets view to tile view on double tap.
  144. *
  145. * @param {Object} e - The event.
  146. * @private
  147. * @returns {void}
  148. */
  149. _onDoubleTap(e) {
  150. e.stopPropagation();
  151. e.preventDefault();
  152. if (this._tappedTimeout) {
  153. this._clearTapTimeout();
  154. this.props.dispatch(setTileView(true));
  155. } else {
  156. this._tappedTimeout = setTimeout(this._clearTapTimeout, 300);
  157. }
  158. }
  159. }
  160. /**
  161. * Maps (parts of) the Redux state to the associated LargeVideo props.
  162. *
  163. * @param {Object} state - The Redux state.
  164. * @private
  165. * @returns {Props}
  166. */
  167. function _mapStateToProps(state) {
  168. const testingConfig = state['features/base/config'].testing;
  169. const { backgroundColor, backgroundImageUrl } = state['features/dynamic-branding'];
  170. const { isOpen: isChatOpen } = state['features/chat'];
  171. return {
  172. _backgroundAlpha: state['features/base/config'].backgroundAlpha,
  173. _customBackgroundColor: backgroundColor,
  174. _customBackgroundImageUrl: backgroundImageUrl,
  175. _isChatOpen: isChatOpen,
  176. _noAutoPlayVideo: testingConfig?.noAutoPlayVideo
  177. };
  178. }
  179. export default connect(_mapStateToProps)(LargeVideo);