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

Thumbnail.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import { Audio, MEDIA_TYPE } from '../../base/media';
  4. import { PARTICIPANT_ROLE, pinParticipant } from '../../base/participants';
  5. import { Container } from '../../base/react';
  6. import { getTrackByMediaTypeAndParticipant } from '../../base/tracks';
  7. import { ParticipantView } from '../../conference';
  8. import {
  9. AudioMutedIndicator,
  10. DominantSpeakerIndicator,
  11. ModeratorIndicator,
  12. styles,
  13. VideoMutedIndicator
  14. } from './_';
  15. /**
  16. * React component for video thumbnail.
  17. * @extends Component
  18. */
  19. class Thumbnail extends Component {
  20. /**
  21. * Thumbnail component's property types.
  22. *
  23. * @static
  24. */
  25. static propTypes = {
  26. audioTrack: React.PropTypes.object,
  27. dispatch: React.PropTypes.func,
  28. largeVideo: React.PropTypes.object,
  29. participant: React.PropTypes.object,
  30. videoTrack: React.PropTypes.object
  31. }
  32. /**
  33. * Initializes new Video Thumbnail component.
  34. *
  35. * @param {Object} props - Component props.
  36. */
  37. constructor(props) {
  38. super(props);
  39. // Bind event handlers so they are only bound once for every instance.
  40. this._onClick = this._onClick.bind(this);
  41. }
  42. /**
  43. * Handles click/tap event on the thumbnail.
  44. *
  45. * @returns {void}
  46. */
  47. _onClick() {
  48. const { dispatch, participant } = this.props;
  49. // TODO The following currently ignores interfaceConfig.filmStripOnly.
  50. dispatch(pinParticipant(participant.pinned ? null : participant.id));
  51. }
  52. /**
  53. * Implements React's {@link Component#render()}.
  54. *
  55. * @inheritdoc
  56. * @returns {ReactElement}
  57. */
  58. render() {
  59. const {
  60. audioTrack,
  61. largeVideo,
  62. participant,
  63. videoTrack
  64. } = this.props;
  65. let style = styles.thumbnail;
  66. if (participant.pinned) {
  67. style = {
  68. ...style,
  69. ...styles.thumbnailPinned
  70. };
  71. }
  72. const thumbToolbarStyle = styles.thumbnailIndicatorContainer;
  73. // We don't render audio in any of the following:
  74. // 1. The audio (source) is muted. There's no practical reason (that we
  75. // know of, anyway) why we'd want to render it given that it's
  76. // silence (& not even comfort noise).
  77. // 2. The audio is local. If we were to render local audio, the local
  78. // participants would be hearing themselves.
  79. const audioMuted = !audioTrack || audioTrack.muted;
  80. const renderAudio = !audioMuted && !audioTrack.local;
  81. const participantId = participant.id;
  82. const participantNotInLargeVideo
  83. = participantId !== largeVideo.participantId;
  84. const videoMuted = !videoTrack || videoTrack.muted;
  85. return (
  86. <Container
  87. onClick = { this._onClick }
  88. style = { style }>
  89. { renderAudio
  90. && <Audio
  91. stream
  92. = { audioTrack.jitsiTrack.getOriginalStream() } /> }
  93. <ParticipantView
  94. participantId = { participantId }
  95. showAvatar = { participantNotInLargeVideo }
  96. showVideo = { participantNotInLargeVideo }
  97. zOrder = { 1 } />
  98. { participant.role === PARTICIPANT_ROLE.MODERATOR
  99. && <ModeratorIndicator /> }
  100. { participant.dominantSpeaker
  101. && <DominantSpeakerIndicator /> }
  102. <Container style = { thumbToolbarStyle }>
  103. { audioMuted
  104. && <AudioMutedIndicator /> }
  105. { videoMuted
  106. && <VideoMutedIndicator /> }
  107. </Container>
  108. </Container>
  109. );
  110. }
  111. }
  112. /**
  113. * Function that maps parts of Redux state tree into component props.
  114. *
  115. * @param {Object} state - Redux state.
  116. * @param {Object} ownProps - Properties of component.
  117. * @returns {{
  118. * audioTrack: Track,
  119. * largeVideo: Object,
  120. * videoTrack: Track
  121. * }}
  122. */
  123. function mapStateToProps(state, ownProps) {
  124. // We need read-only access to the state of features/large-video so that the
  125. // film strip doesn't render the video of the participant who is rendered on
  126. // the stage i.e. as a large video.
  127. const largeVideo = state['features/large-video'];
  128. const tracks = state['features/base/tracks'];
  129. const id = ownProps.participant.id;
  130. const audioTrack
  131. = getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.AUDIO, id);
  132. const videoTrack
  133. = getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, id);
  134. return {
  135. audioTrack,
  136. largeVideo,
  137. videoTrack
  138. };
  139. }
  140. export default connect(mapStateToProps)(Thumbnail);