Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

SharedVideo.tsx 4.0KB

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