Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

SharedVideo.js 3.8KB

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