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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 { fetchCustomBrandingData } from '../../dynamic-branding';
  7. import { SharedVideo } from '../../shared-video/components/web';
  8. import { Captions } from '../../subtitles/';
  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. * Fetches the branding data.
  25. */
  26. _fetchCustomBrandingData: Function,
  27. /**
  28. * Prop that indicates whether the chat is open.
  29. */
  30. _isChatOpen: boolean,
  31. /**
  32. * Used to determine the value of the autoplay attribute of the underlying
  33. * video element.
  34. */
  35. _noAutoPlayVideo: boolean
  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. /**
  45. * Implements React's {@link Component#componentDidMount}.
  46. *
  47. * @inheritdoc
  48. */
  49. componentDidMount() {
  50. this.props._fetchCustomBrandingData();
  51. }
  52. /**
  53. * Implements React's {@link Component#render()}.
  54. *
  55. * @inheritdoc
  56. * @returns {React$Element}
  57. */
  58. render() {
  59. const {
  60. _isChatOpen,
  61. _noAutoPlayVideo
  62. } = this.props;
  63. const style = this._getCustomSyles();
  64. const className = `videocontainer${_isChatOpen ? ' shift-right' : ''}`;
  65. return (
  66. <div
  67. className = { className }
  68. id = 'largeVideoContainer'
  69. style = { style }>
  70. <SharedVideo />
  71. <div id = 'etherpad' />
  72. <Watermarks />
  73. <div id = 'dominantSpeaker'>
  74. <div className = 'dynamic-shadow' />
  75. <div id = 'dominantSpeakerAvatarContainer' />
  76. </div>
  77. <div id = 'remotePresenceMessage' />
  78. <span id = 'remoteConnectionMessage' />
  79. <div id = 'largeVideoElementsContainer'>
  80. <div id = 'largeVideoBackgroundContainer' />
  81. {/*
  82. * FIXME: the architecture of elements related to the large
  83. * video and the naming. The background is not part of
  84. * largeVideoWrapper because we are controlling the size of
  85. * the video through largeVideoWrapper. That's why we need
  86. * another container for the background and the
  87. * largeVideoWrapper in order to hide/show them.
  88. */}
  89. <div id = 'largeVideoWrapper'>
  90. <video
  91. autoPlay = { !_noAutoPlayVideo }
  92. id = 'largeVideo'
  93. muted = { true }
  94. playsInline = { true } /* for Safari on iOS to work */ />
  95. </div>
  96. </div>
  97. { interfaceConfig.DISABLE_TRANSCRIPTION_SUBTITLES
  98. || <Captions /> }
  99. </div>
  100. );
  101. }
  102. /**
  103. * Creates the custom styles object.
  104. *
  105. * @private
  106. * @returns {Object}
  107. */
  108. _getCustomSyles() {
  109. const styles = {};
  110. const { _customBackgroundColor, _customBackgroundImageUrl } = this.props;
  111. styles.backgroundColor = _customBackgroundColor || interfaceConfig.DEFAULT_BACKGROUND;
  112. if (this.props._backgroundAlpha !== undefined) {
  113. const alphaColor = setColorAlpha(styles.backgroundColor, this.props._backgroundAlpha);
  114. styles.backgroundColor = alphaColor;
  115. }
  116. if (_customBackgroundImageUrl) {
  117. styles.backgroundImage = `url(${_customBackgroundImageUrl})`;
  118. styles.backgroundSize = 'cover';
  119. }
  120. return styles;
  121. }
  122. }
  123. /**
  124. * Maps (parts of) the Redux state to the associated LargeVideo props.
  125. *
  126. * @param {Object} state - The Redux state.
  127. * @private
  128. * @returns {Props}
  129. */
  130. function _mapStateToProps(state) {
  131. const testingConfig = state['features/base/config'].testing;
  132. const { backgroundColor, backgroundImageUrl } = state['features/dynamic-branding'];
  133. const { isOpen: isChatOpen } = state['features/chat'];
  134. return {
  135. _backgroundAlpha: state['features/base/config'].backgroundAlpha,
  136. _customBackgroundColor: backgroundColor,
  137. _customBackgroundImageUrl: backgroundImageUrl,
  138. _isChatOpen: isChatOpen,
  139. _noAutoPlayVideo: testingConfig?.noAutoPlayVideo
  140. };
  141. }
  142. const _mapDispatchToProps = {
  143. _fetchCustomBrandingData: fetchCustomBrandingData
  144. };
  145. export default connect(_mapStateToProps, _mapDispatchToProps)(LargeVideo);