2016-10-05 14:36:59 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-01-17 14:44:50 +00:00
|
|
|
import { Audio, MEDIA_TYPE } from '../../base/media';
|
2017-02-27 20:37:53 +00:00
|
|
|
import {
|
|
|
|
PARTICIPANT_ROLE,
|
|
|
|
ParticipantView,
|
|
|
|
pinParticipant
|
|
|
|
} from '../../base/participants';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { Container } from '../../base/react';
|
|
|
|
import { getTrackByMediaTypeAndParticipant } from '../../base/tracks';
|
|
|
|
|
|
|
|
import {
|
|
|
|
AudioMutedIndicator,
|
|
|
|
DominantSpeakerIndicator,
|
|
|
|
ModeratorIndicator,
|
|
|
|
styles,
|
|
|
|
VideoMutedIndicator
|
|
|
|
} from './_';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component for video thumbnail.
|
|
|
|
* @extends Component
|
|
|
|
*/
|
|
|
|
class Thumbnail extends Component {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
|
|
|
* Thumbnail component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
2017-01-28 03:36:20 +00:00
|
|
|
_audioTrack: React.PropTypes.object,
|
|
|
|
_largeVideo: React.PropTypes.object,
|
|
|
|
_videoTrack: React.PropTypes.object,
|
2016-12-01 01:52:39 +00:00
|
|
|
dispatch: React.PropTypes.func,
|
2017-01-28 03:36:20 +00:00
|
|
|
participant: React.PropTypes.object
|
2016-12-01 01:52:39 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes new Video Thumbnail component.
|
|
|
|
*
|
|
|
|
* @param {Object} props - Component props.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2017-01-28 03:36:20 +00:00
|
|
|
const audioTrack = this.props._audioTrack;
|
|
|
|
const largeVideo = this.props._largeVideo;
|
|
|
|
const participant = this.props.participant;
|
|
|
|
const videoTrack = this.props._videoTrack;
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
let style = styles.thumbnail;
|
|
|
|
|
|
|
|
if (participant.pinned) {
|
|
|
|
style = {
|
|
|
|
...style,
|
|
|
|
...styles.thumbnailPinned
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
2016-10-05 14:36:59 +00:00
|
|
|
const participantNotInLargeVideo
|
2016-11-04 18:28:47 +00:00
|
|
|
= participantId !== largeVideo.participantId;
|
2016-10-05 14:36:59 +00:00
|
|
|
const videoMuted = !videoTrack || videoTrack.muted;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container
|
|
|
|
onClick = { this._onClick }
|
|
|
|
style = { style }>
|
|
|
|
|
|
|
|
{ renderAudio
|
|
|
|
&& <Audio
|
|
|
|
stream
|
|
|
|
= { audioTrack.jitsiTrack.getOriginalStream() } /> }
|
|
|
|
|
|
|
|
<ParticipantView
|
2017-04-07 15:26:51 +00:00
|
|
|
avatarStyle = { styles.avatar }
|
2016-11-04 18:28:47 +00:00
|
|
|
participantId = { participantId }
|
2016-10-05 14:36:59 +00:00
|
|
|
showAvatar = { participantNotInLargeVideo }
|
|
|
|
showVideo = { participantNotInLargeVideo }
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|
2017-01-28 23:28:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles click/tap event on the thumbnail.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { dispatch, participant } = this.props;
|
|
|
|
|
|
|
|
// TODO The following currently ignores interfaceConfig.filmStripOnly.
|
|
|
|
dispatch(pinParticipant(participant.pinned ? null : participant.id));
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @param {Object} ownProps - Properties of component.
|
2017-01-28 23:34:57 +00:00
|
|
|
* @private
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-01-28 03:36:20 +00:00
|
|
|
* _audioTrack: Track,
|
|
|
|
* _largeVideo: Object,
|
|
|
|
* _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,
|
|
|
|
_largeVideo: largeVideo,
|
|
|
|
_videoTrack: videoTrack
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-01-28 23:34:57 +00:00
|
|
|
export default connect(_mapStateToProps)(Thumbnail);
|