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.js 3.6KB

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