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 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. declare var interfaceConfig: Object;
  9. type Props = {
  10. /**
  11. * The alpha(opacity) of the background
  12. */
  13. _backgroundAlpha: number,
  14. /**
  15. * The user selected background color.
  16. */
  17. _customBackgroundColor: string,
  18. /**
  19. * The user selected background image url.
  20. */
  21. _customBackgroundImageUrl: string,
  22. /**
  23. * Prop that indicates whether the chat is open.
  24. */
  25. _isChatOpen: boolean,
  26. /**
  27. * Used to determine the value of the autoplay attribute of the underlying
  28. * video element.
  29. */
  30. _noAutoPlayVideo: boolean
  31. }
  32. /**
  33. * Implements a React {@link Component} which represents the large video (a.k.a.
  34. * the conference participant who is on the local stage) on Web/React.
  35. *
  36. * @extends Component
  37. */
  38. class LargeVideo extends Component<Props> {
  39. /**
  40. * Implements React's {@link Component#render()}.
  41. *
  42. * @inheritdoc
  43. * @returns {React$Element}
  44. */
  45. render() {
  46. const {
  47. _isChatOpen,
  48. _noAutoPlayVideo
  49. } = this.props;
  50. const style = this._getCustomSyles();
  51. const className = `videocontainer${_isChatOpen ? ' shift-right' : ''}`;
  52. return (
  53. <div
  54. className = { className }
  55. id = 'largeVideoContainer'
  56. style = { style }>
  57. <SharedVideo />
  58. <div id = 'etherpad' />
  59. <Watermarks />
  60. <div id = 'dominantSpeaker'>
  61. <div className = 'dynamic-shadow' />
  62. <div id = 'dominantSpeakerAvatarContainer' />
  63. </div>
  64. <div id = 'remotePresenceMessage' />
  65. <span id = 'remoteConnectionMessage' />
  66. <div id = 'largeVideoElementsContainer'>
  67. <div id = 'largeVideoBackgroundContainer' />
  68. {/*
  69. * FIXME: the architecture of elements related to the large
  70. * video and the naming. The background is not part of
  71. * largeVideoWrapper because we are controlling the size of
  72. * the video through largeVideoWrapper. That's why we need
  73. * another container for the background and the
  74. * largeVideoWrapper in order to hide/show them.
  75. */}
  76. <div
  77. id = 'largeVideoWrapper'
  78. role = 'figure' >
  79. <video
  80. autoPlay = { !_noAutoPlayVideo }
  81. id = 'largeVideo'
  82. muted = { true }
  83. playsInline = { true } /* for Safari on iOS to work */ />
  84. </div>
  85. </div>
  86. { interfaceConfig.DISABLE_TRANSCRIPTION_SUBTITLES
  87. || <Captions /> }
  88. </div>
  89. );
  90. }
  91. /**
  92. * Creates the custom styles object.
  93. *
  94. * @private
  95. * @returns {Object}
  96. */
  97. _getCustomSyles() {
  98. const styles = {};
  99. const { _customBackgroundColor, _customBackgroundImageUrl } = this.props;
  100. styles.backgroundColor = _customBackgroundColor || interfaceConfig.DEFAULT_BACKGROUND;
  101. if (this.props._backgroundAlpha !== undefined) {
  102. const alphaColor = setColorAlpha(styles.backgroundColor, this.props._backgroundAlpha);
  103. styles.backgroundColor = alphaColor;
  104. }
  105. if (_customBackgroundImageUrl) {
  106. styles.backgroundImage = `url(${_customBackgroundImageUrl})`;
  107. styles.backgroundSize = 'cover';
  108. }
  109. return styles;
  110. }
  111. }
  112. /**
  113. * Maps (parts of) the Redux state to the associated LargeVideo props.
  114. *
  115. * @param {Object} state - The Redux state.
  116. * @private
  117. * @returns {Props}
  118. */
  119. function _mapStateToProps(state) {
  120. const testingConfig = state['features/base/config'].testing;
  121. const { backgroundColor, backgroundImageUrl } = state['features/dynamic-branding'];
  122. const { isOpen: isChatOpen } = state['features/chat'];
  123. return {
  124. _backgroundAlpha: state['features/base/config'].backgroundAlpha,
  125. _customBackgroundColor: backgroundColor,
  126. _customBackgroundImageUrl: backgroundImageUrl,
  127. _isChatOpen: isChatOpen,
  128. _noAutoPlayVideo: testingConfig?.noAutoPlayVideo
  129. };
  130. }
  131. export default connect(_mapStateToProps)(LargeVideo);