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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 { Subject } from '../../conference';
  7. import { fetchCustomBrandingData } from '../../dynamic-branding';
  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 style = this._getCustomSyles();
  60. const className = `videocontainer${this.props._isChatOpen ? ' shift-right' : ''}`;
  61. return (
  62. <div
  63. className = { className }
  64. id = 'largeVideoContainer'
  65. style = { style }>
  66. <Subject />
  67. <div id = 'sharedVideo'>
  68. <div id = 'sharedVideoIFrame' />
  69. </div>
  70. <div id = 'etherpad' />
  71. <Watermarks />
  72. <div id = 'dominantSpeaker'>
  73. <div className = 'dynamic-shadow' />
  74. <div id = 'dominantSpeakerAvatarContainer' />
  75. </div>
  76. <div id = 'remotePresenceMessage' />
  77. <span id = 'remoteConnectionMessage' />
  78. <div id = 'largeVideoElementsContainer'>
  79. <div id = 'largeVideoBackgroundContainer' />
  80. {/*
  81. * FIXME: the architecture of elements related to the large
  82. * video and the naming. The background is not part of
  83. * largeVideoWrapper because we are controlling the size of
  84. * the video through largeVideoWrapper. That's why we need
  85. * another container for the background and the
  86. * largeVideoWrapper in order to hide/show them.
  87. */}
  88. <div id = 'largeVideoWrapper'>
  89. <video
  90. autoPlay = { !this.props._noAutoPlayVideo }
  91. id = 'largeVideo'
  92. muted = { true }
  93. playsInline = { true } /* for Safari on iOS to work */ />
  94. </div>
  95. </div>
  96. { interfaceConfig.DISABLE_TRANSCRIPTION_SUBTITLES
  97. || <Captions /> }
  98. </div>
  99. );
  100. }
  101. /**
  102. * Creates the custom styles object.
  103. *
  104. * @private
  105. * @returns {Object}
  106. */
  107. _getCustomSyles() {
  108. const styles = {};
  109. const { _customBackgroundColor, _customBackgroundImageUrl } = this.props;
  110. styles.backgroundColor = _customBackgroundColor || interfaceConfig.DEFAULT_BACKGROUND;
  111. if (this.props._backgroundAlpha !== undefined) {
  112. const alphaColor = setColorAlpha(styles.backgroundColor, this.props._backgroundAlpha);
  113. styles.backgroundColor = alphaColor;
  114. }
  115. if (_customBackgroundImageUrl) {
  116. styles.backgroundImage = `url(${_customBackgroundImageUrl})`;
  117. styles.backgroundSize = 'cover';
  118. }
  119. return styles;
  120. }
  121. }
  122. /**
  123. * Maps (parts of) the Redux state to the associated LargeVideo props.
  124. *
  125. * @param {Object} state - The Redux state.
  126. * @private
  127. * @returns {Props}
  128. */
  129. function _mapStateToProps(state) {
  130. const testingConfig = state['features/base/config'].testing;
  131. const { backgroundColor, backgroundImageUrl } = state['features/dynamic-branding'];
  132. const { isOpen: isChatOpen } = state['features/chat'];
  133. return {
  134. _backgroundAlpha: state['features/base/config'].backgroundAlpha,
  135. _customBackgroundColor: backgroundColor,
  136. _customBackgroundImageUrl: backgroundImageUrl,
  137. _isChatOpen: isChatOpen,
  138. _noAutoPlayVideo: testingConfig?.noAutoPlayVideo
  139. };
  140. }
  141. const _mapDispatchToProps = {
  142. _fetchCustomBrandingData: fetchCustomBrandingData
  143. };
  144. export default connect(_mapStateToProps, _mapDispatchToProps)(LargeVideo);