You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Preview.js 2.1KB

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