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

LargeVideo.web.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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
  90. id = 'largeVideoWrapper'
  91. role = 'figure' >
  92. <video
  93. autoPlay = { !_noAutoPlayVideo }
  94. id = 'largeVideo'
  95. muted = { true }
  96. playsInline = { true } /* for Safari on iOS to work */ />
  97. </div>
  98. </div>
  99. { interfaceConfig.DISABLE_TRANSCRIPTION_SUBTITLES
  100. || <Captions /> }
  101. </div>
  102. );
  103. }
  104. /**
  105. * Creates the custom styles object.
  106. *
  107. * @private
  108. * @returns {Object}
  109. */
  110. _getCustomSyles() {
  111. const styles = {};
  112. const { _customBackgroundColor, _customBackgroundImageUrl } = this.props;
  113. styles.backgroundColor = _customBackgroundColor || interfaceConfig.DEFAULT_BACKGROUND;
  114. if (this.props._backgroundAlpha !== undefined) {
  115. const alphaColor = setColorAlpha(styles.backgroundColor, this.props._backgroundAlpha);
  116. styles.backgroundColor = alphaColor;
  117. }
  118. if (_customBackgroundImageUrl) {
  119. styles.backgroundImage = `url(${_customBackgroundImageUrl})`;
  120. styles.backgroundSize = 'cover';
  121. }
  122. return styles;
  123. }
  124. }
  125. /**
  126. * Maps (parts of) the Redux state to the associated LargeVideo props.
  127. *
  128. * @param {Object} state - The Redux state.
  129. * @private
  130. * @returns {Props}
  131. */
  132. function _mapStateToProps(state) {
  133. const testingConfig = state['features/base/config'].testing;
  134. const { backgroundColor, backgroundImageUrl } = state['features/dynamic-branding'];
  135. const { isOpen: isChatOpen } = state['features/chat'];
  136. return {
  137. _backgroundAlpha: state['features/base/config'].backgroundAlpha,
  138. _customBackgroundColor: backgroundColor,
  139. _customBackgroundImageUrl: backgroundImageUrl,
  140. _isChatOpen: isChatOpen,
  141. _noAutoPlayVideo: testingConfig?.noAutoPlayVideo
  142. };
  143. }
  144. const _mapDispatchToProps = {
  145. _fetchCustomBrandingData: fetchCustomBrandingData
  146. };
  147. export default connect(_mapStateToProps, _mapDispatchToProps)(LargeVideo);