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.

SharedVideo.tsx 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. // @ts-expect-error
  4. import Filmstrip from '../../../../../modules/UI/videolayout/Filmstrip';
  5. import { IReduxState } from '../../../app/types';
  6. import { getVerticalViewMaxWidth } from '../../../filmstrip/functions.web';
  7. import { getToolboxHeight } from '../../../toolbox/functions.web';
  8. import { isSharedVideoEnabled } from '../../functions';
  9. import VideoManager from './VideoManager';
  10. import YoutubeVideoManager from './YoutubeVideoManager';
  11. interface IProps {
  12. /**
  13. * The available client width.
  14. */
  15. clientHeight: number;
  16. /**
  17. * The available client width.
  18. */
  19. clientWidth: number;
  20. /**
  21. * Whether the (vertical) filmstrip is visible or not.
  22. */
  23. filmstripVisible: boolean;
  24. /**
  25. * The width of the vertical filmstrip.
  26. */
  27. filmstripWidth: number;
  28. /**
  29. * Whether the shared video is enabled or not.
  30. */
  31. isEnabled: boolean;
  32. /**
  33. * Whether or not the user is actively resizing the filmstrip.
  34. */
  35. isResizing: boolean;
  36. /**
  37. * The shared video url.
  38. */
  39. videoUrl?: string;
  40. }
  41. /** .
  42. * Implements a React {@link Component} which represents the large video (a.k.a.
  43. * The conference participant who is on the local stage) on Web/React.
  44. *
  45. * @augments Component
  46. */
  47. class SharedVideo extends Component<IProps> {
  48. /**
  49. * Computes the width and the height of the component.
  50. *
  51. * @returns {{
  52. * height: number,
  53. * width: number
  54. * }}
  55. */
  56. getDimensions() {
  57. const { clientHeight, clientWidth, filmstripVisible, filmstripWidth } = this.props;
  58. let width;
  59. let height;
  60. if (interfaceConfig.VERTICAL_FILMSTRIP) {
  61. if (filmstripVisible) {
  62. width = `${clientWidth - filmstripWidth}px`;
  63. } else {
  64. width = `${clientWidth}px`;
  65. }
  66. height = `${clientHeight - getToolboxHeight()}px`;
  67. } else {
  68. if (filmstripVisible) {
  69. height = `${clientHeight - Filmstrip.getFilmstripHeight()}px`;
  70. } else {
  71. height = `${clientHeight}px`;
  72. }
  73. width = `${clientWidth}px`;
  74. }
  75. return {
  76. width,
  77. height
  78. };
  79. }
  80. /**
  81. * Retrieves the manager to be used for playing the shared video.
  82. *
  83. * @returns {Component}
  84. */
  85. getManager() {
  86. const { videoUrl } = this.props;
  87. if (!videoUrl) {
  88. return null;
  89. }
  90. if (videoUrl.match(/http/)) {
  91. return <VideoManager videoId = { videoUrl } />;
  92. }
  93. return <YoutubeVideoManager videoId = { videoUrl } />;
  94. }
  95. /**
  96. * Implements React's {@link Component#render()}.
  97. *
  98. * @inheritdoc
  99. * @returns {React$Element}
  100. */
  101. render() {
  102. const { isEnabled, isResizing } = this.props;
  103. if (!isEnabled) {
  104. return null;
  105. }
  106. return (
  107. <div
  108. className = { (isResizing && 'disable-pointer') || '' }
  109. id = 'sharedVideo'
  110. style = { this.getDimensions() }>
  111. {this.getManager()}
  112. </div>
  113. );
  114. }
  115. }
  116. /**
  117. * Maps (parts of) the Redux state to the associated LargeVideo props.
  118. *
  119. * @param {Object} state - The Redux state.
  120. * @private
  121. * @returns {IProps}
  122. */
  123. function _mapStateToProps(state: IReduxState) {
  124. const { videoUrl } = state['features/shared-video'];
  125. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  126. const { visible, isResizing } = state['features/filmstrip'];
  127. return {
  128. clientHeight,
  129. clientWidth,
  130. filmstripVisible: visible,
  131. filmstripWidth: getVerticalViewMaxWidth(state),
  132. isEnabled: isSharedVideoEnabled(state),
  133. isResizing,
  134. videoUrl
  135. };
  136. }
  137. export default connect(_mapStateToProps)(SharedVideo);