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

Preview.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // @flow
  2. import React from 'react';
  3. import { Video } from '../../../media';
  4. import { connect } from '../../../redux';
  5. import { getLocalVideoTrack } from '../../../tracks';
  6. import PreviewAvatar from './Avatar';
  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. <PreviewAvatar name = { name } />
  48. </div>
  49. );
  50. }
  51. return null;
  52. }
  53. Preview.defaultProps = {
  54. showAvatar: true
  55. };
  56. /**
  57. * Maps part of the Redux state to the props of this component.
  58. *
  59. * @param {Object} state - The Redux state.
  60. * @param {Props} ownProps - The own props of the component.
  61. * @returns {Props}
  62. */
  63. function _mapStateToProps(state, ownProps) {
  64. return {
  65. videoMuted: ownProps.videoTrack ? ownProps.videoMuted : state['features/base/media'].video.muted,
  66. videoTrack: ownProps.videoTrack || (getLocalVideoTrack(state['features/base/tracks']) || {}).jitsiTrack
  67. };
  68. }
  69. export default connect(_mapStateToProps)(Preview);