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

Preview.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // @flow
  2. import React from 'react';
  3. import { getDisplayName } from '../../../../base/settings';
  4. import { Avatar } from '../../../avatar';
  5. import { Video } from '../../../media';
  6. import { getLocalParticipant } from '../../../participants';
  7. import { connect } from '../../../redux';
  8. import { getLocalVideoTrack } from '../../../tracks';
  9. export type Props = {
  10. /**
  11. * Local participant id
  12. */
  13. _participantId: string,
  14. /**
  15. * Flag controlling whether the video should be flipped or not.
  16. */
  17. flipVideo: boolean,
  18. /**
  19. * The name of the user that is about to join.
  20. */
  21. name: string,
  22. /**
  23. * Flag signaling the visibility of camera preview.
  24. */
  25. videoMuted: boolean,
  26. /**
  27. * The JitsiLocalTrack to display.
  28. */
  29. videoTrack: ?Object,
  30. };
  31. /**
  32. * Component showing the video preview and device status.
  33. *
  34. * @param {Props} props - The props of the component.
  35. * @returns {ReactElement}
  36. */
  37. function Preview(props: Props) {
  38. const { _participantId, flipVideo, name, videoMuted, videoTrack } = props;
  39. const className = flipVideo ? 'flipVideoX' : '';
  40. return (
  41. <div id = 'preview'>
  42. {!videoMuted && videoTrack
  43. ? (
  44. <Video
  45. className = { className }
  46. videoTrack = {{ jitsiTrack: videoTrack }} />
  47. )
  48. : (
  49. <Avatar
  50. className = 'premeeting-screen-avatar'
  51. displayName = { name }
  52. dynamicColor = { false }
  53. participantId = { _participantId }
  54. size = { 180 } />
  55. )}
  56. </div>
  57. );
  58. }
  59. /**
  60. * Maps part of the Redux state to the props of this component.
  61. *
  62. * @param {Object} state - The Redux state.
  63. * @param {Props} ownProps - The own props of the component.
  64. * @returns {Props}
  65. */
  66. function _mapStateToProps(state, ownProps) {
  67. const name = getDisplayName(state);
  68. const { id: _participantId } = getLocalParticipant(state);
  69. return {
  70. _participantId,
  71. flipVideo: state['features/base/settings'].localFlipX,
  72. name,
  73. videoMuted: ownProps.videoTrack ? ownProps.videoMuted : state['features/base/media'].video.muted,
  74. videoTrack: ownProps.videoTrack || (getLocalVideoTrack(state['features/base/tracks']) || {}).jitsiTrack
  75. };
  76. }
  77. export default connect(_mapStateToProps)(Preview);