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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React, { useEffect } from 'react';
  2. import { connect } from 'react-redux';
  3. import { IReduxState } from '../../../../app/types';
  4. import Avatar from '../../../avatar/components/Avatar';
  5. import Video from '../../../media/components/web/Video';
  6. import { getLocalParticipant } from '../../../participants/functions';
  7. import { getDisplayName } from '../../../settings/functions.web';
  8. import { getLocalVideoTrack } from '../../../tracks/functions.web';
  9. export interface IProps {
  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 {IProps} props - The props of the component.
  35. * @returns {ReactElement}
  36. */
  37. function Preview(props: IProps) {
  38. const { _participantId, flipVideo, name, videoMuted, videoTrack } = props;
  39. const className = flipVideo ? 'flipVideoX' : '';
  40. useEffect(() => {
  41. APP.API.notifyPrejoinVideoVisibilityChanged(Boolean(!videoMuted && videoTrack));
  42. }, [ videoMuted, videoTrack ]);
  43. useEffect(() => {
  44. APP.API.notifyPrejoinLoaded();
  45. return () => APP.API.notifyPrejoinVideoVisibilityChanged(false);
  46. }, []);
  47. return (
  48. <div id = 'preview'>
  49. {!videoMuted && videoTrack
  50. ? (
  51. <Video
  52. className = { className }
  53. id = 'prejoinVideo'
  54. videoTrack = {{ jitsiTrack: videoTrack }} />
  55. )
  56. : (
  57. <Avatar
  58. className = 'premeeting-screen-avatar'
  59. displayName = { name }
  60. participantId = { _participantId }
  61. size = { 200 } />
  62. )}
  63. </div>
  64. );
  65. }
  66. /**
  67. * Maps part of the Redux state to the props of this component.
  68. *
  69. * @param {Object} state - The Redux state.
  70. * @param {IProps} ownProps - The own props of the component.
  71. * @returns {IProps}
  72. */
  73. function _mapStateToProps(state: IReduxState, ownProps: any) {
  74. const name = getDisplayName(state);
  75. const { id: _participantId } = getLocalParticipant(state) ?? {};
  76. return {
  77. _participantId: _participantId ?? '',
  78. flipVideo: Boolean(state['features/base/settings'].localFlipX),
  79. name,
  80. videoMuted: ownProps.videoTrack ? ownProps.videoMuted : state['features/base/media'].video.muted,
  81. videoTrack: ownProps.videoTrack || getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack
  82. };
  83. }
  84. export default connect(_mapStateToProps)(Preview);