Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Thumbnail.js 4.6KB

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