2020-11-09 20:59:13 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
import { createScreenSharingIssueEvent, sendAnalytics } from '../../../analytics';
|
2020-11-09 20:59:13 +00:00
|
|
|
import { AudioLevelIndicator } from '../../../audio-level-indicator';
|
|
|
|
import { Avatar } from '../../../base/avatar';
|
2021-09-06 10:01:13 +00:00
|
|
|
import { isNameReadOnly } from '../../../base/config';
|
2021-07-20 08:30:12 +00:00
|
|
|
import { isMobileBrowser } from '../../../base/environment/utils';
|
2020-11-09 20:59:13 +00:00
|
|
|
import JitsiMeetJS from '../../../base/lib-jitsi-meet/_';
|
|
|
|
import { MEDIA_TYPE, VideoTrack } from '../../../base/media';
|
|
|
|
import {
|
2021-07-09 12:36:19 +00:00
|
|
|
getParticipantByIdOrUndefined,
|
2021-01-21 20:46:47 +00:00
|
|
|
getParticipantCount,
|
|
|
|
pinParticipant
|
2020-11-09 20:59:13 +00:00
|
|
|
} from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
2021-09-09 13:14:09 +00:00
|
|
|
import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
|
2021-01-21 20:46:47 +00:00
|
|
|
import { isTestModeEnabled } from '../../../base/testing';
|
|
|
|
import {
|
|
|
|
getLocalAudioTrack,
|
|
|
|
getLocalVideoTrack,
|
|
|
|
getTrackByMediaTypeAndParticipant,
|
|
|
|
updateLastTrackVideoMediaEvent
|
|
|
|
} from '../../../base/tracks';
|
2020-11-09 20:59:13 +00:00
|
|
|
import { ConnectionIndicator } from '../../../connection-indicator';
|
|
|
|
import { DisplayName } from '../../../display-name';
|
|
|
|
import { StatusIndicators, RaisedHandIndicator, DominantSpeakerIndicator } from '../../../filmstrip';
|
|
|
|
import { PresenceLabel } from '../../../presence-status';
|
|
|
|
import { getCurrentLayout, LAYOUTS } from '../../../video-layout';
|
2021-01-21 20:46:47 +00:00
|
|
|
import { LocalVideoMenuTriggerButton, RemoteVideoMenuTriggerButton } from '../../../video-menu';
|
2021-03-26 20:23:05 +00:00
|
|
|
import { setVolume } from '../../actions.web';
|
2021-01-21 20:46:47 +00:00
|
|
|
import {
|
|
|
|
DISPLAY_MODE_TO_CLASS_NAME,
|
|
|
|
DISPLAY_VIDEO,
|
|
|
|
DISPLAY_VIDEO_WITH_NAME,
|
2021-06-30 16:12:12 +00:00
|
|
|
VIDEO_TEST_EVENTS,
|
|
|
|
SHOW_TOOLBAR_CONTEXT_MENU_AFTER
|
2021-01-21 20:46:47 +00:00
|
|
|
} from '../../constants';
|
|
|
|
import { isVideoPlayable, computeDisplayMode } from '../../functions';
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
const JitsiTrackEvents = JitsiMeetJS.events.track;
|
|
|
|
|
|
|
|
declare var interfaceConfig: Object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} state of {@link Thumbnail}.
|
|
|
|
*/
|
2021-01-21 20:46:47 +00:00
|
|
|
export type State = {|
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The current audio level value for the Thumbnail.
|
|
|
|
*/
|
|
|
|
audioLevel: number,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Indicates that the canplay event has been received.
|
|
|
|
*/
|
|
|
|
canPlayEventReceived: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current display mode of the thumbnail.
|
|
|
|
*/
|
|
|
|
displayMode: number,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the thumbnail is hovered or not.
|
|
|
|
*/
|
2021-11-01 09:39:19 +00:00
|
|
|
isHovered: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether popover is visible or not.
|
|
|
|
*/
|
|
|
|
popoverVisible: boolean
|
2021-01-21 20:46:47 +00:00
|
|
|
|};
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link Thumbnail}.
|
|
|
|
*/
|
2021-01-21 20:46:47 +00:00
|
|
|
export type Props = {|
|
2020-11-09 20:59:13 +00:00
|
|
|
|
2021-09-06 10:01:13 +00:00
|
|
|
/**
|
|
|
|
* If the display name is editable or not.
|
|
|
|
*/
|
|
|
|
_allowEditing: boolean,
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* The audio track related to the participant.
|
|
|
|
*/
|
|
|
|
_audioTrack: ?Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable/enable the auto hide functionality for the connection indicator.
|
|
|
|
*/
|
|
|
|
_connectionIndicatorAutoHideEnabled: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable/enable the connection indicator.
|
|
|
|
*/
|
|
|
|
_connectionIndicatorDisabled: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current layout of the filmstrip.
|
|
|
|
*/
|
|
|
|
_currentLayout: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The default display name for the local participant.
|
|
|
|
*/
|
|
|
|
_defaultLocalDisplayName: string,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether the local video flip feature is disabled or not.
|
|
|
|
*/
|
|
|
|
_disableLocalVideoFlip: boolean,
|
|
|
|
|
2021-12-01 10:40:40 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether enlargement of tiles to fill the available space is disabled.
|
|
|
|
*/
|
|
|
|
_disableTileEnlargement: boolean,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* The display mode of the thumbnail.
|
|
|
|
*/
|
|
|
|
_displayMode: number,
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* The height of the Thumbnail.
|
|
|
|
*/
|
|
|
|
_height: number,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The aspect ratio of the Thumbnail in percents.
|
|
|
|
*/
|
|
|
|
_heightToWidthPercent: number,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether the thumbnail should be hidden or not.
|
|
|
|
*/
|
|
|
|
_isHidden: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether audio only mode is enabled.
|
|
|
|
*/
|
|
|
|
_isAudioOnly: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the participant associated with the thumbnail is displayed on the large video.
|
|
|
|
*/
|
|
|
|
_isCurrentlyOnLargeVideo: boolean,
|
|
|
|
|
2021-07-20 08:30:12 +00:00
|
|
|
/**
|
|
|
|
* Whether we are currently running in a mobile browser.
|
|
|
|
*/
|
|
|
|
_isMobile: boolean,
|
|
|
|
|
2021-09-09 13:14:09 +00:00
|
|
|
/**
|
|
|
|
* Whether we are currently running in a mobile browser in portrait orientation.
|
|
|
|
*/
|
|
|
|
_isMobilePortrait: boolean,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether the participant is screen sharing.
|
|
|
|
*/
|
|
|
|
_isScreenSharing: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the video associated with the thumbnail is playable.
|
|
|
|
*/
|
|
|
|
_isVideoPlayable: boolean,
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* Disable/enable the dominant speaker indicator.
|
|
|
|
*/
|
|
|
|
_isDominantSpeakerDisabled: boolean,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether testing mode is enabled.
|
|
|
|
*/
|
|
|
|
_isTestModeEnabled: boolean,
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* The size of the icon of indicators.
|
|
|
|
*/
|
|
|
|
_indicatorIconSize: number,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* The current local video flip setting.
|
|
|
|
*/
|
|
|
|
_localFlipX: boolean,
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
2021-10-22 12:35:33 +00:00
|
|
|
* An object with information about the participant related to the thumbnail.
|
2020-11-09 20:59:13 +00:00
|
|
|
*/
|
|
|
|
_participant: Object,
|
|
|
|
|
|
|
|
/**
|
2021-03-26 20:23:05 +00:00
|
|
|
* True if there are more than 2 participants in the call.
|
2020-11-09 20:59:13 +00:00
|
|
|
*/
|
2021-03-26 20:23:05 +00:00
|
|
|
_participantCountMoreThan2: boolean,
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the "start silent" mode is enabled.
|
|
|
|
*/
|
|
|
|
_startSilent: Boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The video track that will be displayed in the thumbnail.
|
|
|
|
*/
|
|
|
|
_videoTrack: ?Object,
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
|
|
|
* The volume level for the thumbnail.
|
|
|
|
*/
|
|
|
|
_volume?: ?number,
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* The width of the thumbnail.
|
|
|
|
*/
|
|
|
|
_width: number,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
|
|
|
* The horizontal offset in px for the thumbnail. Used to center the thumbnails from the last row in tile view.
|
|
|
|
*/
|
|
|
|
horizontalOffset: number,
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* The ID of the participant related to the thumbnail.
|
|
|
|
*/
|
2021-03-26 20:23:05 +00:00
|
|
|
participantID: ?string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Styles that will be set to the Thumbnail's main span element.
|
|
|
|
*/
|
|
|
|
style?: ?Object
|
2021-01-21 20:46:47 +00:00
|
|
|
|};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler for the display name container.
|
|
|
|
*
|
|
|
|
* @param {SyntheticEvent} event - The click event.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function onClick(event) {
|
|
|
|
// If the event is propagated to the thumbnail container the participant will be pinned. That's why the propagation
|
|
|
|
// needs to be stopped.
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a thumbnail.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2020-11-09 20:59:13 +00:00
|
|
|
*/
|
|
|
|
class Thumbnail extends Component<Props, State> {
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
|
|
|
* The long touch setTimeout handler.
|
|
|
|
*/
|
|
|
|
timeoutHandle: Object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reference to local or remote Video Menu trigger button instance.
|
|
|
|
*/
|
|
|
|
videoMenuTriggerRef: Object;
|
|
|
|
|
2021-10-25 09:16:03 +00:00
|
|
|
/**
|
|
|
|
* Timeout used to detect double tapping.
|
|
|
|
* It is active while user has tapped once.
|
|
|
|
*/
|
|
|
|
_firstTap: ?TimeoutID;
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new Thumbnail instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
const state = {
|
2020-11-09 20:59:13 +00:00
|
|
|
audioLevel: 0,
|
2021-01-21 20:46:47 +00:00
|
|
|
canPlayEventReceived: false,
|
|
|
|
isHovered: false,
|
2021-11-01 09:39:19 +00:00
|
|
|
displayMode: DISPLAY_VIDEO,
|
|
|
|
popoverVisible: false
|
2021-01-21 20:46:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
...state,
|
2021-11-01 09:39:19 +00:00
|
|
|
displayMode: computeDisplayMode(Thumbnail.getDisplayModeInput(props, state)),
|
|
|
|
popoverVisible: false
|
2020-11-09 20:59:13 +00:00
|
|
|
};
|
2021-06-30 16:12:12 +00:00
|
|
|
this.timeoutHandle = null;
|
|
|
|
this.videoMenuTriggerRef = null;
|
2020-11-09 20:59:13 +00:00
|
|
|
|
2021-10-25 09:16:03 +00:00
|
|
|
this._clearDoubleClickTimeout = this._clearDoubleClickTimeout.bind(this);
|
2020-11-09 20:59:13 +00:00
|
|
|
this._updateAudioLevel = this._updateAudioLevel.bind(this);
|
2021-01-21 20:46:47 +00:00
|
|
|
this._onCanPlay = this._onCanPlay.bind(this);
|
|
|
|
this._onClick = this._onClick.bind(this);
|
2020-11-09 20:59:13 +00:00
|
|
|
this._onVolumeChange = this._onVolumeChange.bind(this);
|
2021-01-21 20:46:47 +00:00
|
|
|
this._onMouseEnter = this._onMouseEnter.bind(this);
|
|
|
|
this._onMouseLeave = this._onMouseLeave.bind(this);
|
|
|
|
this._onTestingEvent = this._onTestingEvent.bind(this);
|
2021-06-30 16:12:12 +00:00
|
|
|
this._onTouchStart = this._onTouchStart.bind(this);
|
|
|
|
this._onTouchEnd = this._onTouchEnd.bind(this);
|
|
|
|
this._onTouchMove = this._onTouchMove.bind(this);
|
2021-11-01 09:39:19 +00:00
|
|
|
this._showPopover = this._showPopover.bind(this);
|
|
|
|
this._hidePopover = this._hidePopover.bind(this);
|
2020-11-09 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts listening for audio level updates after the initial render.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
|
|
|
this._listenForAudioUpdates();
|
2021-01-21 20:46:47 +00:00
|
|
|
this._onDisplayModeChanged();
|
2020-11-09 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops listening for audio level updates on the old track and starts
|
|
|
|
* listening instead on the new track.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-01-21 20:46:47 +00:00
|
|
|
componentDidUpdate(prevProps: Props, prevState: State) {
|
2020-11-09 20:59:13 +00:00
|
|
|
if (prevProps._audioTrack !== this.props._audioTrack) {
|
|
|
|
this._stopListeningForAudioUpdates(prevProps._audioTrack);
|
|
|
|
this._listenForAudioUpdates();
|
|
|
|
this._updateAudioLevel(0);
|
|
|
|
}
|
2021-01-21 20:46:47 +00:00
|
|
|
|
|
|
|
if (prevState.displayMode !== this.state.displayMode) {
|
|
|
|
this._onDisplayModeChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles display mode changes.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onDisplayModeChanged() {
|
|
|
|
const input = Thumbnail.getDisplayModeInput(this.props, this.state);
|
|
|
|
|
|
|
|
this._maybeSendScreenSharingIssueEvents(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends screen sharing issue event if an issue is detected.
|
|
|
|
*
|
|
|
|
* @param {Object} input - The input used to compute the thumbnail display mode.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_maybeSendScreenSharingIssueEvents(input) {
|
|
|
|
const {
|
|
|
|
_currentLayout,
|
|
|
|
_isAudioOnly,
|
|
|
|
_isScreenSharing
|
|
|
|
} = this.props;
|
|
|
|
const { displayMode } = this.state;
|
|
|
|
const tileViewActive = _currentLayout === LAYOUTS.TILE_VIEW;
|
|
|
|
|
|
|
|
if (![ DISPLAY_VIDEO, DISPLAY_VIDEO_WITH_NAME ].includes(displayMode)
|
|
|
|
&& tileViewActive
|
|
|
|
&& _isScreenSharing
|
|
|
|
&& !_isAudioOnly) {
|
|
|
|
sendAnalytics(createScreenSharingIssueEvent({
|
|
|
|
source: 'thumbnail',
|
|
|
|
...input
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#getDerivedStateFromProps()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
static getDerivedStateFromProps(props: Props, prevState: State) {
|
|
|
|
if (!props._videoTrack && prevState.canPlayEventReceived) {
|
|
|
|
const newState = {
|
|
|
|
...prevState,
|
|
|
|
canPlayEventReceived: false
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
...newState,
|
2021-05-06 20:07:45 +00:00
|
|
|
displayMode: computeDisplayMode(Thumbnail.getDisplayModeInput(props, newState))
|
2021-01-21 20:46:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const newDisplayMode = computeDisplayMode(Thumbnail.getDisplayModeInput(props, prevState));
|
|
|
|
|
|
|
|
if (newDisplayMode !== prevState.displayMode) {
|
|
|
|
return {
|
|
|
|
...prevState,
|
|
|
|
displayMode: newDisplayMode
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extracts information for props and state needed to compute the display mode.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The component's props.
|
|
|
|
* @param {State} state - The component's state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
static getDisplayModeInput(props: Props, state: State) {
|
|
|
|
const {
|
|
|
|
_currentLayout,
|
|
|
|
_isAudioOnly,
|
|
|
|
_isCurrentlyOnLargeVideo,
|
|
|
|
_isScreenSharing,
|
|
|
|
_isVideoPlayable,
|
|
|
|
_participant,
|
|
|
|
_videoTrack
|
|
|
|
} = props;
|
|
|
|
const tileViewActive = _currentLayout === LAYOUTS.TILE_VIEW;
|
|
|
|
const { canPlayEventReceived, isHovered } = state;
|
|
|
|
|
|
|
|
return {
|
|
|
|
isCurrentlyOnLargeVideo: _isCurrentlyOnLargeVideo,
|
|
|
|
isHovered,
|
|
|
|
isAudioOnly: _isAudioOnly,
|
|
|
|
tileViewActive,
|
|
|
|
isVideoPlayable: _isVideoPlayable,
|
|
|
|
connectionStatus: _participant?.connectionStatus,
|
|
|
|
canPlayEventReceived,
|
|
|
|
videoStream: Boolean(_videoTrack),
|
|
|
|
isRemoteParticipant: !_participant?.isFakeParticipant && !_participant?.local,
|
|
|
|
isScreenSharing: _isScreenSharing,
|
|
|
|
videoStreamMuted: _videoTrack ? _videoTrack.muted : 'no stream'
|
|
|
|
};
|
2020-11-09 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unsubscribe from audio level updates.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
|
|
|
this._stopListeningForAudioUpdates(this.props._audioTrack);
|
|
|
|
}
|
|
|
|
|
2021-11-04 21:10:43 +00:00
|
|
|
_clearDoubleClickTimeout: () => void;
|
2021-10-25 09:16:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears the first click timeout.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_clearDoubleClickTimeout() {
|
|
|
|
clearTimeout(this._firstTap);
|
|
|
|
this._firstTap = undefined;
|
|
|
|
}
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* Starts listening for audio level updates from the library.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_listenForAudioUpdates() {
|
|
|
|
const { _audioTrack } = this.props;
|
|
|
|
|
|
|
|
if (_audioTrack) {
|
|
|
|
const { jitsiTrack } = _audioTrack;
|
|
|
|
|
|
|
|
jitsiTrack && jitsiTrack.on(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED, this._updateAudioLevel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops listening to further updates from the passed track.
|
|
|
|
*
|
|
|
|
* @param {Object} audioTrack - The track.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_stopListeningForAudioUpdates(audioTrack) {
|
|
|
|
if (audioTrack) {
|
|
|
|
const { jitsiTrack } = audioTrack;
|
|
|
|
|
|
|
|
jitsiTrack && jitsiTrack.off(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED, this._updateAudioLevel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateAudioLevel: (number) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the internal state of the last know audio level. The level should
|
|
|
|
* be between 0 and 1, as the level will be used as a percentage out of 1.
|
|
|
|
*
|
|
|
|
* @param {number} audioLevel - The new audio level for the track.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_updateAudioLevel(audioLevel) {
|
|
|
|
this.setState({
|
|
|
|
audioLevel
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-01 09:39:19 +00:00
|
|
|
_showPopover: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows popover.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_showPopover() {
|
|
|
|
this.setState({
|
|
|
|
popoverVisible: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_hidePopover: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides popover.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_hidePopover() {
|
|
|
|
this.setState({
|
|
|
|
popoverVisible: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* Returns an object with the styles for thumbnail.
|
|
|
|
*
|
|
|
|
* @returns {Object} - The styles for the thumbnail.
|
|
|
|
*/
|
|
|
|
_getStyles(): Object {
|
2021-10-26 08:46:01 +00:00
|
|
|
|
|
|
|
const { canPlayEventReceived } = this.state;
|
|
|
|
const {
|
2021-11-24 03:26:22 +00:00
|
|
|
_currentLayout,
|
2021-12-01 10:40:40 +00:00
|
|
|
_disableTileEnlargement,
|
2021-10-26 08:46:01 +00:00
|
|
|
_height,
|
|
|
|
_isHidden,
|
|
|
|
_isScreenSharing,
|
|
|
|
_participant,
|
|
|
|
_width,
|
|
|
|
horizontalOffset,
|
|
|
|
style
|
|
|
|
} = this.props;
|
|
|
|
|
2021-11-24 03:26:22 +00:00
|
|
|
const tileViewActive = _currentLayout === LAYOUTS.TILE_VIEW;
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
let styles: {
|
2021-10-26 08:46:01 +00:00
|
|
|
avatar: Object,
|
2021-01-21 20:46:47 +00:00
|
|
|
thumbnail: Object,
|
2021-10-26 08:46:01 +00:00
|
|
|
video: Object
|
2021-01-21 20:46:47 +00:00
|
|
|
} = {
|
|
|
|
thumbnail: {},
|
2021-10-26 08:46:01 +00:00
|
|
|
avatar: {},
|
|
|
|
video: {}
|
2021-01-21 20:46:47 +00:00
|
|
|
};
|
2020-11-09 20:59:13 +00:00
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
const avatarSize = _height / 2;
|
|
|
|
let { left } = style || {};
|
|
|
|
|
|
|
|
if (typeof left === 'number' && horizontalOffset) {
|
|
|
|
left += horizontalOffset;
|
2020-11-09 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-26 08:46:01 +00:00
|
|
|
let videoStyles = null;
|
|
|
|
|
|
|
|
if (!_isScreenSharing) {
|
|
|
|
if (canPlayEventReceived || _participant.local) {
|
|
|
|
videoStyles = {
|
2021-12-01 10:40:40 +00:00
|
|
|
objectFit: (_height < 320 && tileViewActive) || _disableTileEnlargement ? 'contain' : 'cover'
|
2021-10-26 08:46:01 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
videoStyles = {
|
|
|
|
display: 'none'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
styles = {
|
|
|
|
thumbnail: {
|
|
|
|
...style,
|
|
|
|
left,
|
|
|
|
height: `${_height}px`,
|
|
|
|
minHeight: `${_height}px`,
|
|
|
|
minWidth: `${_width}px`,
|
|
|
|
width: `${_width}px`
|
|
|
|
},
|
|
|
|
avatar: {
|
|
|
|
height: `${avatarSize}px`,
|
|
|
|
width: `${avatarSize}px`
|
2021-10-26 08:46:01 +00:00
|
|
|
},
|
|
|
|
video: videoStyles
|
2021-03-26 20:23:05 +00:00
|
|
|
};
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
if (_isHidden) {
|
|
|
|
styles.thumbnail.display = 'none';
|
|
|
|
}
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
return styles;
|
|
|
|
}
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
_onClick: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On click handler.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { _participant, dispatch } = this.props;
|
|
|
|
const { id, pinned } = _participant;
|
|
|
|
|
|
|
|
dispatch(pinParticipant(pinned ? null : id));
|
|
|
|
}
|
|
|
|
|
|
|
|
_onMouseEnter: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mouse enter handler.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onMouseEnter() {
|
|
|
|
this.setState({ isHovered: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
_onMouseLeave: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mouse leave handler.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onMouseLeave() {
|
|
|
|
this.setState({ isHovered: false });
|
|
|
|
}
|
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
_onTouchStart: () => void;
|
|
|
|
|
|
|
|
/**
|
2021-10-25 09:16:03 +00:00
|
|
|
* Handler for touch start.
|
2021-06-30 16:12:12 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onTouchStart() {
|
2021-11-01 09:39:19 +00:00
|
|
|
this.timeoutHandle = setTimeout(this._showPopover, SHOW_TOOLBAR_CONTEXT_MENU_AFTER);
|
2021-10-25 09:16:03 +00:00
|
|
|
|
|
|
|
if (this._firstTap) {
|
|
|
|
this._clearDoubleClickTimeout();
|
|
|
|
this._onClick();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._firstTap = setTimeout(this._clearDoubleClickTimeout, 300);
|
2021-06-30 16:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onTouchEnd: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel showing popover context menu after x miliseconds if the no. Of miliseconds is not reached yet,
|
|
|
|
* or just clears the timeout.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onTouchEnd() {
|
|
|
|
clearTimeout(this.timeoutHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onTouchMove: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel showing Context menu after x miliseconds if the number of miliseconds is not reached
|
|
|
|
* before a touch move(drag), or just clears the timeout.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onTouchMove() {
|
|
|
|
clearTimeout(this.timeoutHandle);
|
|
|
|
}
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* Renders a fake participant (youtube video) thumbnail.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the participant.
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderFakeParticipant() {
|
2021-07-20 08:30:12 +00:00
|
|
|
const { _isMobile, _participant: { avatarURL } } = this.props;
|
2021-01-21 20:46:47 +00:00
|
|
|
const styles = this._getStyles();
|
|
|
|
const containerClassName = this._getContainerClassName();
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
return (
|
2021-01-21 20:46:47 +00:00
|
|
|
<span
|
|
|
|
className = { containerClassName }
|
|
|
|
id = 'sharedVideoContainer'
|
|
|
|
onClick = { this._onClick }
|
2021-07-20 08:30:12 +00:00
|
|
|
{ ...(_isMobile ? {} : {
|
|
|
|
onMouseEnter: this._onMouseEnter,
|
|
|
|
onMouseLeave: this._onMouseLeave
|
|
|
|
}) }
|
2021-01-21 20:46:47 +00:00
|
|
|
style = { styles.thumbnail }>
|
2021-04-16 09:43:34 +00:00
|
|
|
{avatarURL ? (
|
|
|
|
<img
|
|
|
|
className = 'sharedVideoAvatar'
|
|
|
|
src = { avatarURL } />
|
|
|
|
)
|
|
|
|
: this._renderAvatar(styles.avatar)}
|
2021-01-21 20:46:47 +00:00
|
|
|
</span>
|
2020-11-09 20:59:13 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-07 20:34:40 +00:00
|
|
|
* Renders the top indicators of the thumbnail.
|
2020-11-09 20:59:13 +00:00
|
|
|
*
|
|
|
|
* @returns {Component}
|
|
|
|
*/
|
2021-01-07 20:34:40 +00:00
|
|
|
_renderTopIndicators() {
|
2020-11-09 20:59:13 +00:00
|
|
|
const {
|
|
|
|
_connectionIndicatorAutoHideEnabled,
|
|
|
|
_connectionIndicatorDisabled,
|
|
|
|
_currentLayout,
|
|
|
|
_isDominantSpeakerDisabled,
|
|
|
|
_indicatorIconSize: iconSize,
|
|
|
|
_participant,
|
2021-03-26 20:23:05 +00:00
|
|
|
_participantCountMoreThan2
|
2020-11-09 20:59:13 +00:00
|
|
|
} = this.props;
|
2021-01-21 20:46:47 +00:00
|
|
|
const { isHovered } = this.state;
|
2020-11-09 20:59:13 +00:00
|
|
|
const showConnectionIndicator = isHovered || !_connectionIndicatorAutoHideEnabled;
|
2021-07-08 11:19:17 +00:00
|
|
|
const { id, dominantSpeaker = false } = _participant;
|
2020-11-09 20:59:13 +00:00
|
|
|
const showDominantSpeaker = !_isDominantSpeakerDisabled && dominantSpeaker;
|
|
|
|
let statsPopoverPosition, tooltipPosition;
|
|
|
|
|
|
|
|
switch (_currentLayout) {
|
|
|
|
case LAYOUTS.TILE_VIEW:
|
2021-01-14 16:12:08 +00:00
|
|
|
statsPopoverPosition = 'right-start';
|
2020-11-09 20:59:13 +00:00
|
|
|
tooltipPosition = 'right';
|
|
|
|
break;
|
|
|
|
case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
|
2021-01-14 16:12:08 +00:00
|
|
|
statsPopoverPosition = 'left-start';
|
2020-11-09 20:59:13 +00:00
|
|
|
tooltipPosition = 'left';
|
|
|
|
break;
|
2021-08-16 09:58:48 +00:00
|
|
|
case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
|
|
|
|
statsPopoverPosition = 'top';
|
|
|
|
tooltipPosition = 'top';
|
|
|
|
break;
|
2020-11-09 20:59:13 +00:00
|
|
|
default:
|
2021-01-14 16:12:08 +00:00
|
|
|
statsPopoverPosition = 'auto';
|
2020-11-09 20:59:13 +00:00
|
|
|
tooltipPosition = 'top';
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2021-01-21 20:46:47 +00:00
|
|
|
{ !_connectionIndicatorDisabled
|
|
|
|
&& <ConnectionIndicator
|
|
|
|
alwaysVisible = { showConnectionIndicator }
|
|
|
|
enableStatsDisplay = { true }
|
2020-11-09 20:59:13 +00:00
|
|
|
iconSize = { iconSize }
|
|
|
|
participantId = { id }
|
2021-01-21 20:46:47 +00:00
|
|
|
statsPopoverPosition = { statsPopoverPosition } />
|
|
|
|
}
|
|
|
|
<RaisedHandIndicator
|
|
|
|
iconSize = { iconSize }
|
|
|
|
participantId = { id }
|
|
|
|
tooltipPosition = { tooltipPosition } />
|
2021-03-26 20:23:05 +00:00
|
|
|
{ showDominantSpeaker && _participantCountMoreThan2
|
2021-01-21 20:46:47 +00:00
|
|
|
&& <DominantSpeakerIndicator
|
|
|
|
iconSize = { iconSize }
|
2020-11-09 20:59:13 +00:00
|
|
|
tooltipPosition = { tooltipPosition } />
|
2021-01-21 20:46:47 +00:00
|
|
|
}
|
2020-11-09 20:59:13 +00:00
|
|
|
</div>);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the avatar.
|
|
|
|
*
|
2021-01-21 20:46:47 +00:00
|
|
|
* @param {Object} styles - The styles that will be applied to the avatar.
|
2020-11-09 20:59:13 +00:00
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
2021-01-21 20:46:47 +00:00
|
|
|
_renderAvatar(styles) {
|
2020-11-09 20:59:13 +00:00
|
|
|
const { _participant } = this.props;
|
|
|
|
const { id } = _participant;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className = 'avatar-container'
|
2021-01-21 20:46:47 +00:00
|
|
|
style = { styles }>
|
2020-11-09 20:59:13 +00:00
|
|
|
<Avatar
|
|
|
|
className = 'userAvatar'
|
|
|
|
participantId = { id } />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Returns the container class name.
|
|
|
|
*
|
|
|
|
* @returns {string} - The class name that will be used for the container.
|
|
|
|
*/
|
|
|
|
_getContainerClassName() {
|
|
|
|
let className = 'videocontainer';
|
|
|
|
const { displayMode } = this.state;
|
|
|
|
const { _isAudioOnly, _isDominantSpeakerDisabled, _isHidden, _participant } = this.props;
|
|
|
|
const isRemoteParticipant = !_participant?.local && !_participant?.isFakeParticipant;
|
|
|
|
|
|
|
|
className += ` ${DISPLAY_MODE_TO_CLASS_NAME[displayMode]}`;
|
|
|
|
|
|
|
|
if (_participant?.pinned) {
|
|
|
|
className += ' videoContainerFocused';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_isDominantSpeakerDisabled && _participant?.dominantSpeaker) {
|
|
|
|
className += ' active-speaker';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_isHidden) {
|
|
|
|
className += ' hidden';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isRemoteParticipant && _isAudioOnly) {
|
|
|
|
className += ' audio-only';
|
|
|
|
}
|
|
|
|
|
|
|
|
return className;
|
|
|
|
}
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* Renders the local participant's thumbnail.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderLocalParticipant() {
|
|
|
|
const {
|
2021-09-06 10:01:13 +00:00
|
|
|
_allowEditing,
|
2020-11-09 20:59:13 +00:00
|
|
|
_defaultLocalDisplayName,
|
2021-01-21 20:46:47 +00:00
|
|
|
_disableLocalVideoFlip,
|
2021-07-20 08:30:12 +00:00
|
|
|
_isMobile,
|
2021-09-09 13:14:09 +00:00
|
|
|
_isMobilePortrait,
|
2021-01-21 20:46:47 +00:00
|
|
|
_isScreenSharing,
|
|
|
|
_localFlipX,
|
2020-11-09 20:59:13 +00:00
|
|
|
_participant,
|
|
|
|
_videoTrack
|
|
|
|
} = this.props;
|
|
|
|
const { id } = _participant || {};
|
2021-01-07 21:05:29 +00:00
|
|
|
const { audioLevel } = this.state;
|
2021-01-21 20:46:47 +00:00
|
|
|
const styles = this._getStyles();
|
2021-09-21 07:40:46 +00:00
|
|
|
let containerClassName = this._getContainerClassName();
|
2021-01-21 20:46:47 +00:00
|
|
|
const videoTrackClassName
|
|
|
|
= !_disableLocalVideoFlip && _videoTrack && !_isScreenSharing && _localFlipX ? 'flipVideoX' : '';
|
2020-11-09 20:59:13 +00:00
|
|
|
|
2021-09-21 07:40:46 +00:00
|
|
|
if (_isMobilePortrait) {
|
|
|
|
styles.thumbnail.height = styles.thumbnail.width;
|
|
|
|
containerClassName = `${containerClassName} self-view-mobile-portrait`;
|
|
|
|
}
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
return (
|
2021-01-21 20:46:47 +00:00
|
|
|
<span
|
|
|
|
className = { containerClassName }
|
|
|
|
id = 'localVideoContainer'
|
2021-07-20 08:30:12 +00:00
|
|
|
{ ...(_isMobile
|
|
|
|
? {
|
|
|
|
onTouchEnd: this._onTouchEnd,
|
|
|
|
onTouchMove: this._onTouchMove,
|
|
|
|
onTouchStart: this._onTouchStart
|
|
|
|
}
|
|
|
|
: {
|
2021-10-25 09:16:03 +00:00
|
|
|
onClick: this._onClick,
|
2021-07-20 08:30:12 +00:00
|
|
|
onMouseEnter: this._onMouseEnter,
|
|
|
|
onMouseLeave: this._onMouseLeave
|
|
|
|
}
|
|
|
|
) }
|
2021-01-21 20:46:47 +00:00
|
|
|
style = { styles.thumbnail }>
|
2020-11-09 20:59:13 +00:00
|
|
|
<div className = 'videocontainer__background' />
|
|
|
|
<span id = 'localVideoWrapper'>
|
|
|
|
<VideoTrack
|
2021-01-21 20:46:47 +00:00
|
|
|
className = { videoTrackClassName }
|
2020-11-09 20:59:13 +00:00
|
|
|
id = 'localVideo_container'
|
2021-10-26 08:46:01 +00:00
|
|
|
style = { styles.video }
|
2020-11-09 20:59:13 +00:00
|
|
|
videoTrack = { _videoTrack } />
|
|
|
|
</span>
|
|
|
|
<div className = 'videocontainer__toolbar'>
|
|
|
|
<StatusIndicators participantID = { id } />
|
2021-10-25 13:35:40 +00:00
|
|
|
<div
|
|
|
|
className = 'videocontainer__participant-name'
|
|
|
|
onClick = { onClick }>
|
|
|
|
<DisplayName
|
|
|
|
allowEditing = { _allowEditing }
|
|
|
|
displayNameSuffix = { _defaultLocalDisplayName }
|
|
|
|
elementID = 'localDisplayName'
|
|
|
|
participantID = { id } />
|
|
|
|
</div>
|
2020-11-09 20:59:13 +00:00
|
|
|
</div>
|
|
|
|
<div className = 'videocontainer__toptoolbar'>
|
2021-01-07 20:34:40 +00:00
|
|
|
{ this._renderTopIndicators() }
|
2020-11-09 20:59:13 +00:00
|
|
|
</div>
|
|
|
|
<div className = 'videocontainer__hoverOverlay' />
|
2021-01-21 20:46:47 +00:00
|
|
|
{ this._renderAvatar(styles.avatar) }
|
2020-11-09 20:59:13 +00:00
|
|
|
<span className = 'audioindicator-container'>
|
|
|
|
<AudioLevelIndicator audioLevel = { audioLevel } />
|
|
|
|
</span>
|
2021-06-10 12:48:44 +00:00
|
|
|
<span className = 'localvideomenu'>
|
2021-06-30 16:12:12 +00:00
|
|
|
<LocalVideoMenuTriggerButton
|
2021-11-01 09:39:19 +00:00
|
|
|
hidePopover = { this._hidePopover }
|
|
|
|
popoverVisible = { this.state.popoverVisible }
|
|
|
|
showPopover = { this._showPopover } />
|
2021-06-10 12:48:44 +00:00
|
|
|
</span>
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
</span>
|
2020-11-09 20:59:13 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
_onCanPlay: Object => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Canplay event listener.
|
|
|
|
*
|
|
|
|
* @param {SyntheticEvent} event - The event.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onCanPlay(event) {
|
|
|
|
this.setState({ canPlayEventReceived: true });
|
|
|
|
|
|
|
|
const {
|
|
|
|
_isTestModeEnabled,
|
|
|
|
_videoTrack
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (_videoTrack && _isTestModeEnabled) {
|
|
|
|
this._onTestingEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_onTestingEvent: Object => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for testing events.
|
|
|
|
*
|
|
|
|
* @param {SyntheticEvent} event - The event.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onTestingEvent(event) {
|
|
|
|
const {
|
|
|
|
_videoTrack,
|
|
|
|
dispatch
|
|
|
|
} = this.props;
|
|
|
|
const jitsiVideoTrack = _videoTrack?.jitsiTrack;
|
|
|
|
|
|
|
|
dispatch(updateLastTrackVideoMediaEvent(jitsiVideoTrack, event.type));
|
|
|
|
}
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a remote participant's 'thumbnail.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderRemoteParticipant() {
|
|
|
|
const {
|
2021-07-20 08:30:12 +00:00
|
|
|
_isMobile,
|
2021-01-21 20:46:47 +00:00
|
|
|
_isTestModeEnabled,
|
2020-11-09 20:59:13 +00:00
|
|
|
_participant,
|
2021-01-21 20:46:47 +00:00
|
|
|
_startSilent,
|
2021-03-26 20:23:05 +00:00
|
|
|
_videoTrack,
|
|
|
|
_volume = 1
|
2020-11-09 20:59:13 +00:00
|
|
|
} = this.props;
|
|
|
|
const { id } = _participant;
|
2021-10-26 08:46:01 +00:00
|
|
|
const { audioLevel } = this.state;
|
2021-01-21 20:46:47 +00:00
|
|
|
const styles = this._getStyles();
|
|
|
|
const containerClassName = this._getContainerClassName();
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
// hide volume when in silent mode
|
|
|
|
const onVolumeChange = _startSilent ? undefined : this._onVolumeChange;
|
2021-01-21 20:46:47 +00:00
|
|
|
const jitsiVideoTrack = _videoTrack?.jitsiTrack;
|
|
|
|
const videoTrackId = jitsiVideoTrack && jitsiVideoTrack.getId();
|
|
|
|
const videoEventListeners = {};
|
|
|
|
|
|
|
|
if (_videoTrack && _isTestModeEnabled) {
|
|
|
|
VIDEO_TEST_EVENTS.forEach(attribute => {
|
|
|
|
videoEventListeners[attribute] = this._onTestingEvent;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
videoEventListeners.onCanPlay = this._onCanPlay;
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
return (
|
2021-01-21 20:46:47 +00:00
|
|
|
<span
|
|
|
|
className = { containerClassName }
|
|
|
|
id = { `participant_${id}` }
|
2021-07-20 08:30:12 +00:00
|
|
|
{ ...(_isMobile
|
|
|
|
? {
|
|
|
|
onTouchEnd: this._onTouchEnd,
|
|
|
|
onTouchMove: this._onTouchMove,
|
|
|
|
onTouchStart: this._onTouchStart
|
|
|
|
}
|
|
|
|
: {
|
2021-10-25 11:19:13 +00:00
|
|
|
onClick: this._onClick,
|
2021-07-20 08:30:12 +00:00
|
|
|
onMouseEnter: this._onMouseEnter,
|
|
|
|
onMouseLeave: this._onMouseLeave
|
|
|
|
}
|
|
|
|
) }
|
2021-01-21 20:46:47 +00:00
|
|
|
style = { styles.thumbnail }>
|
2020-11-09 20:59:13 +00:00
|
|
|
{
|
2021-01-21 20:46:47 +00:00
|
|
|
_videoTrack && <VideoTrack
|
|
|
|
eventHandlers = { videoEventListeners }
|
|
|
|
id = { `remoteVideo_${videoTrackId || ''}` }
|
|
|
|
muted = { true }
|
2021-10-26 08:46:01 +00:00
|
|
|
style = { styles.video }
|
2021-01-21 20:46:47 +00:00
|
|
|
videoTrack = { _videoTrack } />
|
|
|
|
}
|
2020-11-09 20:59:13 +00:00
|
|
|
<div className = 'videocontainer__background' />
|
|
|
|
<div className = 'videocontainer__toptoolbar'>
|
2021-01-07 20:34:40 +00:00
|
|
|
{ this._renderTopIndicators() }
|
2020-11-09 20:59:13 +00:00
|
|
|
</div>
|
|
|
|
<div className = 'videocontainer__toolbar'>
|
|
|
|
<StatusIndicators participantID = { id } />
|
2021-10-25 13:35:40 +00:00
|
|
|
<div className = 'videocontainer__participant-name'>
|
|
|
|
<DisplayName
|
|
|
|
elementID = { `participant_${id}_name` }
|
|
|
|
participantID = { id } />
|
|
|
|
</div>
|
2020-11-09 20:59:13 +00:00
|
|
|
</div>
|
|
|
|
<div className = 'videocontainer__hoverOverlay' />
|
2021-01-21 20:46:47 +00:00
|
|
|
{ this._renderAvatar(styles.avatar) }
|
2020-11-09 20:59:13 +00:00
|
|
|
<div className = 'presence-label-container'>
|
|
|
|
<PresenceLabel
|
|
|
|
className = 'presence-label'
|
|
|
|
participantID = { id } />
|
|
|
|
</div>
|
2021-06-10 12:48:44 +00:00
|
|
|
<span className = 'audioindicator-container'>
|
|
|
|
<AudioLevelIndicator audioLevel = { audioLevel } />
|
|
|
|
</span>
|
2020-11-09 20:59:13 +00:00
|
|
|
<span className = 'remotevideomenu'>
|
2021-01-21 20:46:47 +00:00
|
|
|
<RemoteVideoMenuTriggerButton
|
2021-11-01 09:39:19 +00:00
|
|
|
hidePopover = { this._hidePopover }
|
2021-03-26 20:23:05 +00:00
|
|
|
initialVolumeValue = { _volume }
|
2021-01-21 20:46:47 +00:00
|
|
|
onVolumeChange = { onVolumeChange }
|
2021-11-01 09:39:19 +00:00
|
|
|
participantID = { id }
|
|
|
|
popoverVisible = { this.state.popoverVisible }
|
|
|
|
showPopover = { this._showPopover } />
|
2020-11-09 20:59:13 +00:00
|
|
|
</span>
|
2021-01-21 20:46:47 +00:00
|
|
|
</span>
|
2020-11-09 20:59:13 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onVolumeChange: number => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles volume changes.
|
|
|
|
*
|
|
|
|
* @param {number} value - The new value for the volume.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onVolumeChange(value) {
|
2021-03-26 20:23:05 +00:00
|
|
|
const { _participant, dispatch } = this.props;
|
|
|
|
const { id } = _participant;
|
|
|
|
|
|
|
|
dispatch(setVolume(id, value));
|
2020-11-09 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const { _participant } = this.props;
|
|
|
|
|
|
|
|
if (!_participant) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-01-06 23:09:31 +00:00
|
|
|
const { isFakeParticipant, local } = _participant;
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
if (local) {
|
|
|
|
return this._renderLocalParticipant();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isFakeParticipant) {
|
|
|
|
return this._renderFakeParticipant();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._renderRemoteParticipant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Object} ownProps - The own props of the component.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state, ownProps): Object {
|
|
|
|
const { participantID } = ownProps;
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
const participant = getParticipantByIdOrUndefined(state, participantID);
|
|
|
|
const id = participant?.id;
|
2020-11-09 20:59:13 +00:00
|
|
|
const isLocal = participant?.local ?? true;
|
2021-01-21 20:46:47 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
2021-03-26 20:23:05 +00:00
|
|
|
const { participantsVolume } = state['features/filmstrip'];
|
2020-11-09 20:59:13 +00:00
|
|
|
const _videoTrack = isLocal
|
2021-01-21 20:46:47 +00:00
|
|
|
? getLocalVideoTrack(tracks) : getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, participantID);
|
2020-11-09 20:59:13 +00:00
|
|
|
const _audioTrack = isLocal
|
2021-01-21 20:46:47 +00:00
|
|
|
? getLocalAudioTrack(tracks) : getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.AUDIO, participantID);
|
2020-11-09 20:59:13 +00:00
|
|
|
const _currentLayout = getCurrentLayout(state);
|
|
|
|
let size = {};
|
2021-09-09 13:14:09 +00:00
|
|
|
let _isMobilePortrait = false;
|
2021-01-21 20:46:47 +00:00
|
|
|
const {
|
|
|
|
startSilent,
|
2021-11-26 15:39:34 +00:00
|
|
|
defaultLocalDisplayName,
|
2021-01-21 20:46:47 +00:00
|
|
|
disableLocalVideoFlip,
|
2021-12-01 10:40:40 +00:00
|
|
|
disableTileEnlargement,
|
2021-01-21 20:46:47 +00:00
|
|
|
iAmRecorder,
|
|
|
|
iAmSipGateway
|
|
|
|
} = state['features/base/config'];
|
2020-11-09 20:59:13 +00:00
|
|
|
const { NORMAL = 8 } = interfaceConfig.INDICATOR_FONT_SIZES || {};
|
2021-01-21 20:46:47 +00:00
|
|
|
const { localFlipX } = state['features/base/settings'];
|
2021-07-20 08:30:12 +00:00
|
|
|
const _isMobile = isMobileBrowser();
|
2020-11-09 20:59:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
switch (_currentLayout) {
|
2021-03-26 20:23:05 +00:00
|
|
|
case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
|
2020-11-09 20:59:13 +00:00
|
|
|
case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW: {
|
|
|
|
const {
|
|
|
|
horizontalViewDimensions = {
|
|
|
|
local: {},
|
|
|
|
remote: {}
|
2021-03-26 20:23:05 +00:00
|
|
|
},
|
|
|
|
verticalViewDimensions = {
|
|
|
|
local: {},
|
|
|
|
remote: {}
|
2020-11-09 20:59:13 +00:00
|
|
|
}
|
|
|
|
} = state['features/filmstrip'];
|
2021-03-26 20:23:05 +00:00
|
|
|
const { local, remote }
|
|
|
|
= _currentLayout === LAYOUTS.VERTICAL_FILMSTRIP_VIEW
|
|
|
|
? verticalViewDimensions : horizontalViewDimensions;
|
2020-11-09 20:59:13 +00:00
|
|
|
const { width, height } = isLocal ? local : remote;
|
|
|
|
|
|
|
|
size = {
|
|
|
|
_width: width,
|
|
|
|
_height: height
|
|
|
|
};
|
|
|
|
|
2021-09-09 13:14:09 +00:00
|
|
|
_isMobilePortrait = _isMobile && state['features/base/responsive-ui'].aspectRatio === ASPECT_RATIO_NARROW;
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LAYOUTS.TILE_VIEW: {
|
2021-09-09 13:14:09 +00:00
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
const { width, height } = state['features/filmstrip'].tileViewDimensions.thumbnailSize;
|
|
|
|
|
|
|
|
size = {
|
|
|
|
_width: width,
|
|
|
|
_height: height
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2021-09-06 10:01:13 +00:00
|
|
|
_allowEditing: !isNameReadOnly(state),
|
2020-11-09 20:59:13 +00:00
|
|
|
_audioTrack,
|
2021-09-09 12:50:22 +00:00
|
|
|
_connectionIndicatorAutoHideEnabled:
|
|
|
|
Boolean(state['features/base/config'].connectionIndicators?.autoHide ?? true),
|
|
|
|
_connectionIndicatorDisabled: _isMobile
|
|
|
|
|| Boolean(state['features/base/config'].connectionIndicators?.disabled),
|
2020-11-09 20:59:13 +00:00
|
|
|
_currentLayout,
|
2021-11-26 15:39:34 +00:00
|
|
|
_defaultLocalDisplayName: defaultLocalDisplayName,
|
2021-01-21 20:46:47 +00:00
|
|
|
_disableLocalVideoFlip: Boolean(disableLocalVideoFlip),
|
2021-12-01 10:40:40 +00:00
|
|
|
_disableTileEnlargement: Boolean(disableTileEnlargement),
|
2021-01-21 20:46:47 +00:00
|
|
|
_isHidden: isLocal && iAmRecorder && !iAmSipGateway,
|
|
|
|
_isAudioOnly: Boolean(state['features/base/audio-only'].enabled),
|
|
|
|
_isCurrentlyOnLargeVideo: state['features/large-video']?.participantId === id,
|
2020-11-09 20:59:13 +00:00
|
|
|
_isDominantSpeakerDisabled: interfaceConfig.DISABLE_DOMINANT_SPEAKER_INDICATOR,
|
2021-07-20 08:30:12 +00:00
|
|
|
_isMobile,
|
2021-09-09 13:14:09 +00:00
|
|
|
_isMobilePortrait,
|
2021-01-21 20:46:47 +00:00
|
|
|
_isScreenSharing: _videoTrack?.videoType === 'desktop',
|
|
|
|
_isTestModeEnabled: isTestModeEnabled(state),
|
2021-07-09 12:36:19 +00:00
|
|
|
_isVideoPlayable: id && isVideoPlayable(state, id),
|
2020-11-09 20:59:13 +00:00
|
|
|
_indicatorIconSize: NORMAL,
|
2021-01-21 20:46:47 +00:00
|
|
|
_localFlipX: Boolean(localFlipX),
|
2020-11-09 20:59:13 +00:00
|
|
|
_participant: participant,
|
2021-03-26 20:23:05 +00:00
|
|
|
_participantCountMoreThan2: getParticipantCount(state) > 2,
|
2020-11-09 20:59:13 +00:00
|
|
|
_startSilent: Boolean(startSilent),
|
|
|
|
_videoTrack,
|
2021-07-09 12:36:19 +00:00
|
|
|
_volume: isLocal ? undefined : id ? participantsVolume[id] : undefined,
|
2020-11-09 20:59:13 +00:00
|
|
|
...size
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(Thumbnail);
|