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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. isOwner: boolean,
  27. /**
  28. * The shared video url.
  29. */
  30. videoUrl: string,
  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. * @augments Component
  37. */
  38. class SharedVideo extends Component<Props> {
  39. /**
  40. * Computes the width and the height of the component.
  41. *
  42. * @returns {{
  43. * height: number,
  44. * width: number
  45. * }}
  46. */
  47. getDimensions() {
  48. const { clientHeight, clientWidth, filmstripVisible } = this.props;
  49. let width;
  50. let height;
  51. if (interfaceConfig.VERTICAL_FILMSTRIP) {
  52. if (filmstripVisible) {
  53. width = `${clientWidth - Filmstrip.getVerticalFilmstripWidth()}px`;
  54. } else {
  55. width = `${clientWidth}px`;
  56. }
  57. height = `${clientHeight - getToolboxHeight()}px`;
  58. } else {
  59. if (filmstripVisible) {
  60. height = `${clientHeight - Filmstrip.getFilmstripHeight()}px`;
  61. } else {
  62. height = `${clientHeight}px`;
  63. }
  64. width = `${clientWidth}px`;
  65. }
  66. return {
  67. width,
  68. height
  69. };
  70. }
  71. /**
  72. * Retrieves the manager to be used for playing the shared video.
  73. *
  74. * @returns {Component}
  75. */
  76. getManager() {
  77. const { videoUrl } = this.props;
  78. if (!videoUrl) {
  79. return null;
  80. }
  81. if (videoUrl.match(/http/)) {
  82. return <VideoManager videoId = { videoUrl } />;
  83. }
  84. return <YoutubeVideoManager videoId = { videoUrl } />;
  85. }
  86. /**
  87. * Implements React's {@link Component#render()}.
  88. *
  89. * @inheritdoc
  90. * @returns {React$Element}
  91. */
  92. render() {
  93. const { isOwner } = this.props;
  94. const className = isOwner ? '' : 'disable-pointer';
  95. return (
  96. <div
  97. className = { className }
  98. id = 'sharedVideo'
  99. style = { this.getDimensions() }>
  100. {this.getManager()}
  101. </div>
  102. );
  103. }
  104. }
  105. /**
  106. * Maps (parts of) the Redux state to the associated LargeVideo props.
  107. *
  108. * @param {Object} state - The Redux state.
  109. * @private
  110. * @returns {Props}
  111. */
  112. function _mapStateToProps(state) {
  113. const { ownerId, videoUrl } = state['features/shared-video'];
  114. const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  115. const { visible } = state['features/filmstrip'];
  116. const localParticipant = getLocalParticipant(state);
  117. return {
  118. clientHeight,
  119. clientWidth,
  120. filmstripVisible: visible,
  121. isOwner: ownerId === localParticipant?.id,
  122. videoUrl
  123. };
  124. }
  125. export default connect(_mapStateToProps)(SharedVideo);