2018-09-13 15:20:22 +00:00
|
|
|
// @flow
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
2018-12-19 18:40:17 +00:00
|
|
|
import { openDialog } from '../../../base/dialog';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { Audio, MEDIA_TYPE } from '../../../base/media';
|
2017-02-27 20:37:53 +00:00
|
|
|
import {
|
|
|
|
PARTICIPANT_ROLE,
|
|
|
|
ParticipantView,
|
2018-12-19 18:40:17 +00:00
|
|
|
isLocalParticipantModerator,
|
2017-02-27 20:37:53 +00:00
|
|
|
pinParticipant
|
2018-05-10 23:01:55 +00:00
|
|
|
} from '../../../base/participants';
|
|
|
|
import { Container } from '../../../base/react';
|
2019-01-22 10:35:28 +00:00
|
|
|
import { StyleType } from '../../../base/styles';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { getTrackByMediaTypeAndParticipant } from '../../../base/tracks';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2018-12-19 18:40:17 +00:00
|
|
|
import { RemoteVideoMenu } from '../../../remote-video-menu';
|
|
|
|
|
2018-05-10 23:01:55 +00:00
|
|
|
import AudioMutedIndicator from './AudioMutedIndicator';
|
|
|
|
import DominantSpeakerIndicator from './DominantSpeakerIndicator';
|
|
|
|
import ModeratorIndicator from './ModeratorIndicator';
|
|
|
|
import { AVATAR_SIZE } from '../styles';
|
|
|
|
import styles from './styles';
|
|
|
|
import VideoMutedIndicator from './VideoMutedIndicator';
|
2018-02-05 10:57:40 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2018-09-13 15:20:22 +00:00
|
|
|
* Thumbnail component's property types.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2018-09-13 15:20:22 +00:00
|
|
|
type Props = {
|
|
|
|
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2018-09-13 15:20:22 +00:00
|
|
|
* The Redux representation of the participant's audio track.
|
|
|
|
*/
|
|
|
|
_audioTrack: Object,
|
|
|
|
|
2018-12-19 18:40:17 +00:00
|
|
|
/**
|
|
|
|
* True if the local participant is a moderator.
|
|
|
|
*/
|
|
|
|
_isModerator: boolean,
|
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
|
|
|
* The Redux representation of the state "features/large-video".
|
|
|
|
*/
|
|
|
|
_largeVideo: Object,
|
|
|
|
|
2019-01-05 16:49:21 +00:00
|
|
|
/**
|
|
|
|
* Handles click/tap event on the thumbnail.
|
|
|
|
*/
|
|
|
|
_onClick: ?Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles long press on the thumbnail.
|
|
|
|
*/
|
|
|
|
_onShowRemoteVideoMenu: ?Function,
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the feature.
|
|
|
|
*/
|
|
|
|
_styles: StyleType,
|
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
|
|
|
* The Redux representation of the participant's video track.
|
|
|
|
*/
|
|
|
|
_videoTrack: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, tapping on the thumbnail will not pin the participant to large
|
|
|
|
* video. By default tapping does pin the participant.
|
|
|
|
*/
|
|
|
|
disablePin?: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, there will be no color overlay (tint) on the thumbnail
|
|
|
|
* indicating the participant associated with the thumbnail is displayed on
|
|
|
|
* large video. By default there will be a tint.
|
2016-12-01 01:52:39 +00:00
|
|
|
*/
|
2018-09-13 15:20:22 +00:00
|
|
|
disableTint?: boolean,
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
|
|
|
* Invoked to trigger state changes in Redux.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
dispatch: Dispatch<any>,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Redux representation of the participant to display.
|
|
|
|
*/
|
|
|
|
participant: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional styling to add or override on the Thumbnail component root.
|
|
|
|
*/
|
|
|
|
styleOverrides?: Object
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component for video thumbnail.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
|
|
|
class Thumbnail extends Component<Props> {
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-09-13 15:20:22 +00:00
|
|
|
const {
|
|
|
|
_audioTrack: audioTrack,
|
2018-12-19 18:40:17 +00:00
|
|
|
_isModerator,
|
2018-09-13 15:20:22 +00:00
|
|
|
_largeVideo: largeVideo,
|
2019-01-05 16:49:21 +00:00
|
|
|
_onClick,
|
|
|
|
_onShowRemoteVideoMenu,
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles,
|
2018-09-13 15:20:22 +00:00
|
|
|
_videoTrack: videoTrack,
|
|
|
|
disablePin,
|
|
|
|
disableTint,
|
|
|
|
participant
|
|
|
|
} = this.props;
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
// We don't render audio in any of the following:
|
|
|
|
// 1. The audio (source) is muted. There's no practical reason (that we
|
|
|
|
// know of, anyway) why we'd want to render it given that it's
|
|
|
|
// silence (& not even comfort noise).
|
|
|
|
// 2. The audio is local. If we were to render local audio, the local
|
|
|
|
// participants would be hearing themselves.
|
|
|
|
const audioMuted = !audioTrack || audioTrack.muted;
|
|
|
|
const renderAudio = !audioMuted && !audioTrack.local;
|
2016-11-04 18:28:47 +00:00
|
|
|
const participantId = participant.id;
|
2018-07-10 15:27:48 +00:00
|
|
|
const participantInLargeVideo
|
|
|
|
= participantId === largeVideo.participantId;
|
2016-10-05 14:36:59 +00:00
|
|
|
const videoMuted = !videoTrack || videoTrack.muted;
|
2018-12-19 18:40:17 +00:00
|
|
|
const showRemoteVideoMenu = _isModerator && !participant.local;
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Container
|
2019-01-05 16:49:21 +00:00
|
|
|
onClick = { disablePin ? undefined : _onClick }
|
2018-12-19 18:40:17 +00:00
|
|
|
onLongPress = {
|
2018-12-21 10:17:08 +00:00
|
|
|
showRemoteVideoMenu
|
2019-01-05 16:49:21 +00:00
|
|
|
? _onShowRemoteVideoMenu : undefined }
|
2018-09-13 15:20:22 +00:00
|
|
|
style = { [
|
|
|
|
styles.thumbnail,
|
|
|
|
participant.pinned && !disablePin
|
2019-01-22 10:35:28 +00:00
|
|
|
? _styles.thumbnailPinned : null,
|
2018-09-13 15:20:22 +00:00
|
|
|
this.props.styleOverrides || null
|
2018-12-21 11:46:39 +00:00
|
|
|
] }
|
|
|
|
touchFeedback = { false }>
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
{ renderAudio
|
|
|
|
&& <Audio
|
|
|
|
stream
|
|
|
|
= { audioTrack.jitsiTrack.getOriginalStream() } /> }
|
|
|
|
|
|
|
|
<ParticipantView
|
2018-02-05 10:57:40 +00:00
|
|
|
avatarSize = { AVATAR_SIZE }
|
2016-11-04 18:28:47 +00:00
|
|
|
participantId = { participantId }
|
2019-01-22 10:35:28 +00:00
|
|
|
style = { _styles.participantViewStyle }
|
2018-09-13 15:20:22 +00:00
|
|
|
tintEnabled = { participantInLargeVideo && !disableTint }
|
2019-01-22 10:35:28 +00:00
|
|
|
tintStyle = { _styles.activeThumbnailTint }
|
2016-10-05 14:36:59 +00:00
|
|
|
zOrder = { 1 } />
|
|
|
|
|
|
|
|
{ participant.role === PARTICIPANT_ROLE.MODERATOR
|
|
|
|
&& <ModeratorIndicator /> }
|
|
|
|
|
2016-11-04 18:28:47 +00:00
|
|
|
{ participant.dominantSpeaker
|
2016-10-05 14:36:59 +00:00
|
|
|
&& <DominantSpeakerIndicator /> }
|
|
|
|
|
2017-04-11 00:14:14 +00:00
|
|
|
<Container style = { styles.thumbnailIndicatorContainer }>
|
2016-12-21 22:32:11 +00:00
|
|
|
{ audioMuted
|
|
|
|
&& <AudioMutedIndicator /> }
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2016-12-21 22:32:11 +00:00
|
|
|
{ videoMuted
|
|
|
|
&& <VideoMutedIndicator /> }
|
|
|
|
</Container>
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2019-01-05 16:49:21 +00:00
|
|
|
}
|
2017-01-28 23:28:13 +00:00
|
|
|
|
2019-01-05 16:49:21 +00:00
|
|
|
/**
|
|
|
|
* Maps part of redux actions to component's props.
|
|
|
|
*
|
|
|
|
* @param {Function} dispatch - Redux's {@code dispatch} function.
|
|
|
|
* @param {Props} ownProps - The own props of the component.
|
|
|
|
* @returns {{
|
|
|
|
* _onClick: Function,
|
|
|
|
* _onShowRemoteVideoMenu: Function
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapDispatchToProps(dispatch: Function, ownProps): Object {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Handles click/tap event on the thumbnail.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { participant } = ownProps;
|
|
|
|
|
|
|
|
dispatch(
|
|
|
|
pinParticipant(participant.pinned ? null : participant.id));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles long press on the thumbnail.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onShowRemoteVideoMenu() {
|
|
|
|
const { participant } = ownProps;
|
|
|
|
|
|
|
|
dispatch(openDialog(RemoteVideoMenu, {
|
|
|
|
participant
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
};
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2019-01-05 16:49:21 +00:00
|
|
|
* @param {Props} ownProps - Properties of component.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-01-28 03:36:20 +00:00
|
|
|
* _audioTrack: Track,
|
2018-12-19 18:40:17 +00:00
|
|
|
* _isModerator: boolean,
|
2017-01-28 03:36:20 +00:00
|
|
|
* _largeVideo: Object,
|
2019-01-22 10:35:28 +00:00
|
|
|
* _styles: StyleType,
|
2017-01-28 03:36:20 +00:00
|
|
|
* _videoTrack: Track
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2017-01-28 23:34:57 +00:00
|
|
|
function _mapStateToProps(state, ownProps) {
|
2017-01-17 14:44:50 +00:00
|
|
|
// We need read-only access to the state of features/large-video so that the
|
2017-04-10 17:59:44 +00:00
|
|
|
// filmstrip doesn't render the video of the participant who is rendered on
|
2016-10-05 14:36:59 +00:00
|
|
|
// the stage i.e. as a large video.
|
2017-01-17 14:44:50 +00:00
|
|
|
const largeVideo = state['features/large-video'];
|
2016-10-05 14:36:59 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
const id = ownProps.participant.id;
|
|
|
|
const audioTrack
|
|
|
|
= getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.AUDIO, id);
|
|
|
|
const videoTrack
|
|
|
|
= getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, id);
|
|
|
|
|
|
|
|
return {
|
2017-01-28 03:36:20 +00:00
|
|
|
_audioTrack: audioTrack,
|
2018-12-19 18:40:17 +00:00
|
|
|
_isModerator: isLocalParticipantModerator(state),
|
2017-01-28 03:36:20 +00:00
|
|
|
_largeVideo: largeVideo,
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles: ColorSchemeRegistry.get(state, 'Thumbnail'),
|
2017-01-28 03:36:20 +00:00
|
|
|
_videoTrack: videoTrack
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-03-19 15:42:25 +00:00
|
|
|
// $FlowExpectedError
|
2019-01-05 16:49:21 +00:00
|
|
|
export default connect(_mapStateToProps, _mapDispatchToProps)(Thumbnail);
|