2020-05-20 08:25:31 +00:00
|
|
|
// @flow
|
|
|
|
|
2022-08-30 08:42:29 +00:00
|
|
|
import React, { useEffect } from 'react';
|
2020-05-20 08:25:31 +00:00
|
|
|
|
2021-08-20 08:53:11 +00:00
|
|
|
import { getDisplayName } from '../../../../base/settings';
|
|
|
|
import { Avatar } from '../../../avatar';
|
2020-05-20 08:25:31 +00:00
|
|
|
import { Video } from '../../../media';
|
2021-08-20 08:53:11 +00:00
|
|
|
import { getLocalParticipant } from '../../../participants';
|
2020-05-20 08:25:31 +00:00
|
|
|
import { connect } from '../../../redux';
|
|
|
|
import { getLocalVideoTrack } from '../../../tracks';
|
|
|
|
|
2022-08-30 08:42:29 +00:00
|
|
|
declare var APP: Object;
|
|
|
|
|
2020-05-20 08:25:31 +00:00
|
|
|
export type Props = {
|
|
|
|
|
2021-08-20 08:53:11 +00:00
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Local participant id.
|
2021-08-20 08:53:11 +00:00
|
|
|
*/
|
|
|
|
_participantId: string,
|
|
|
|
|
2021-03-16 13:45:23 +00:00
|
|
|
/**
|
|
|
|
* Flag controlling whether the video should be flipped or not.
|
|
|
|
*/
|
|
|
|
flipVideo: boolean,
|
|
|
|
|
2021-08-20 08:53:11 +00:00
|
|
|
/**
|
|
|
|
* The name of the user that is about to join.
|
|
|
|
*/
|
|
|
|
name: string,
|
|
|
|
|
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) {
|
2021-08-20 08:53:11 +00:00
|
|
|
const { _participantId, flipVideo, name, videoMuted, videoTrack } = props;
|
2021-03-16 13:45:23 +00:00
|
|
|
const className = flipVideo ? 'flipVideoX' : '';
|
2020-05-20 08:25:31 +00:00
|
|
|
|
2022-08-30 08:42:29 +00:00
|
|
|
useEffect(() => {
|
|
|
|
APP.API.notifyPrejoinVideoVisibilityChanged(Boolean(!videoMuted && videoTrack));
|
|
|
|
}, [ videoMuted, videoTrack ]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
APP.API.notifyPrejoinLoaded();
|
|
|
|
|
|
|
|
return () => APP.API.notifyPrejoinVideoVisibilityChanged(false);
|
|
|
|
}, []);
|
|
|
|
|
2021-08-20 08:53:11 +00:00
|
|
|
return (
|
|
|
|
<div id = 'preview'>
|
|
|
|
{!videoMuted && videoTrack
|
|
|
|
? (
|
|
|
|
<Video
|
|
|
|
className = { className }
|
2022-08-30 08:42:29 +00:00
|
|
|
id = 'prejoinVideo'
|
2021-08-20 08:53:11 +00:00
|
|
|
videoTrack = {{ jitsiTrack: videoTrack }} />
|
|
|
|
)
|
|
|
|
: (
|
|
|
|
<Avatar
|
|
|
|
className = 'premeeting-screen-avatar'
|
|
|
|
displayName = { name }
|
|
|
|
participantId = { _participantId }
|
2021-10-06 11:11:30 +00:00
|
|
|
size = { 200 } />
|
2021-08-20 08:53:11 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
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) {
|
2021-08-20 08:53:11 +00:00
|
|
|
const name = getDisplayName(state);
|
|
|
|
const { id: _participantId } = getLocalParticipant(state);
|
|
|
|
|
2020-05-20 08:25:31 +00:00
|
|
|
return {
|
2021-08-20 08:53:11 +00:00
|
|
|
_participantId,
|
2021-03-16 13:45:23 +00:00
|
|
|
flipVideo: state['features/base/settings'].localFlipX,
|
2021-08-20 08:53:11 +00:00
|
|
|
name,
|
2020-05-20 08:25:31 +00:00
|
|
|
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);
|