您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SharedVideo.js 3.4KB

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