Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Preview.js 2.8KB

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