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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. <Avatar
  48. className = 'preview-avatar'
  49. displayName = { name }
  50. participantId = 'local'
  51. size = { 200 } />
  52. </div>
  53. );
  54. }
  55. return null;
  56. }
  57. Preview.defaultProps = {
  58. showAvatar: true
  59. };
  60. /**
  61. * Maps part of the Redux state to the props of this component.
  62. *
  63. * @param {Object} state - The Redux state.
  64. * @param {Props} ownProps - The own props of the component.
  65. * @returns {Props}
  66. */
  67. function _mapStateToProps(state, ownProps) {
  68. return {
  69. videoMuted: ownProps.videoTrack ? ownProps.videoMuted : state['features/base/media'].video.muted,
  70. videoTrack: ownProps.videoTrack || (getLocalVideoTrack(state['features/base/tracks']) || {}).jitsiTrack
  71. };
  72. }
  73. export default connect(_mapStateToProps)(Preview);