jiti-meet/react/features/base/premeeting/components/web/Preview.js

85 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-05-20 08:25:31 +00:00
// @flow
import React from 'react';
import { Video } from '../../../media';
import { connect } from '../../../redux';
import { getLocalVideoTrack } from '../../../tracks';
2020-08-07 11:46:24 +00:00
import PreviewAvatar from './Avatar';
2020-05-20 08:25:31 +00:00
export type Props = {
/**
* The name of the user that is about to join.
*/
name: string,
2020-06-29 07:45:58 +00:00
/**
* Indicates whether the avatar should be shown when video is off
*/
showAvatar: boolean,
2020-05-20 08:25:31 +00:00
/**
* Flag signaling the visibility of camera preview.
*/
videoMuted: boolean,
/**
* The JitsiLocalTrack to display.
*/
videoTrack: ?Object,
};
/**
* Component showing the video preview and device status.
*
* @param {Props} props - The props of the component.
* @returns {ReactElement}
*/
function Preview(props: Props) {
2020-06-29 07:45:58 +00:00
const { name, showAvatar, videoMuted, videoTrack } = props;
2020-05-20 08:25:31 +00:00
if (!videoMuted && videoTrack) {
return (
<div id = 'preview'>
<Video
className = 'flipVideoX'
videoTrack = {{ jitsiTrack: videoTrack }} />
</div>
);
}
2020-06-29 07:45:58 +00:00
if (showAvatar) {
return (
<div
className = 'no-video'
id = 'preview'>
2020-08-07 11:46:24 +00:00
<PreviewAvatar name = { name } />
2020-06-29 07:45:58 +00:00
</div>
);
}
return null;
2020-05-20 08:25:31 +00:00
}
2020-06-29 07:45:58 +00:00
Preview.defaultProps = {
showAvatar: true
};
2020-05-20 08:25:31 +00:00
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @param {Props} ownProps - The own props of the component.
* @returns {Props}
*/
function _mapStateToProps(state, ownProps) {
return {
videoMuted: ownProps.videoTrack ? ownProps.videoMuted : state['features/base/media'].video.muted,
videoTrack: ownProps.videoTrack || (getLocalVideoTrack(state['features/base/tracks']) || {}).jitsiTrack
};
}
export default connect(_mapStateToProps)(Preview);