123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- import React, { Component } from 'react';
- import { connect } from 'react-redux';
-
- // @ts-expect-error
- import VideoLayout from '../../../../modules/UI/videolayout/VideoLayout';
- import { IReduxState, IStore } from '../../app/types';
- import { VIDEO_TYPE } from '../../base/media/constants';
- import { getLocalParticipant } from '../../base/participants/functions';
- import Watermarks from '../../base/react/components/web/Watermarks';
- import { getHideSelfView } from '../../base/settings/functions.any';
- import { getVideoTrackByParticipant } from '../../base/tracks/functions.web';
- import { setColorAlpha } from '../../base/util/helpers';
- import StageParticipantNameLabel from '../../display-name/components/web/StageParticipantNameLabel';
- import { FILMSTRIP_BREAKPOINT } from '../../filmstrip/constants';
- import { getVerticalViewMaxWidth, isFilmstripResizable } from '../../filmstrip/functions.web';
- import SharedVideo from '../../shared-video/components/web/SharedVideo';
- import Captions from '../../subtitles/components/web/Captions';
- import { setTileView } from '../../video-layout/actions.web';
- import Whiteboard from '../../whiteboard/components/web/Whiteboard';
- import { isWhiteboardEnabled } from '../../whiteboard/functions';
- import { setSeeWhatIsBeingShared } from '../actions.web';
- import { getLargeVideoParticipant } from '../functions';
-
- import ScreenSharePlaceholder from './ScreenSharePlaceholder.web';
-
- // Hack to detect Spot.
- const SPOT_DISPLAY_NAME = 'Meeting Room';
-
- interface IProps {
-
- /**
- * The alpha(opacity) of the background.
- */
- _backgroundAlpha?: number;
-
- /**
- * The user selected background color.
- */
- _customBackgroundColor: string;
-
- /**
- * The user selected background image url.
- */
- _customBackgroundImageUrl: string;
-
- /**
- * Whether the screen-sharing placeholder should be displayed or not.
- */
- _displayScreenSharingPlaceholder: boolean;
-
- /**
- * Whether or not the hideSelfView is enabled.
- */
- _hideSelfView: boolean;
-
- /**
- * Prop that indicates whether the chat is open.
- */
- _isChatOpen: boolean;
-
- /**
- * Whether or not the local screen share is on large-video.
- */
- _isScreenSharing: boolean;
-
- /**
- * The large video participant id.
- */
- _largeVideoParticipantId: string;
-
- /**
- * Local Participant id.
- */
- _localParticipantId: string;
-
- /**
- * Used to determine the value of the autoplay attribute of the underlying
- * video element.
- */
- _noAutoPlayVideo: boolean;
-
- /**
- * Whether or not the filmstrip is resizable.
- */
- _resizableFilmstrip: boolean;
-
- /**
- * Whether or not the screen sharing is visible.
- */
- _seeWhatIsBeingShared: boolean;
-
- /**
- * Whether or not to show dominant speaker badge.
- */
- _showDominantSpeakerBadge: boolean;
-
- /**
- * The width of the vertical filmstrip (user resized).
- */
- _verticalFilmstripWidth?: number | null;
-
- /**
- * The max width of the vertical filmstrip.
- */
- _verticalViewMaxWidth: number;
-
- /**
- * Whether or not the filmstrip is visible.
- */
- _visibleFilmstrip: boolean;
-
- /**
- * Whether or not the whiteboard is enabled.
- */
- _whiteboardEnabled: boolean;
-
- /**
- * The Redux dispatch function.
- */
- dispatch: IStore['dispatch'];
- }
-
- /** .
- * Implements a React {@link Component} which represents the large video (a.k.a.
- * The conference participant who is on the local stage) on Web/React.
- *
- * @augments Component
- */
- class LargeVideo extends Component<IProps> {
- _tappedTimeout: number | undefined;
-
- _containerRef: React.RefObject<HTMLDivElement>;
-
- _wrapperRef: React.RefObject<HTMLDivElement>;
-
- /**
- * Constructor of the component.
- *
- * @inheritdoc
- */
- constructor(props: IProps) {
- super(props);
-
- this._containerRef = React.createRef<HTMLDivElement>();
- this._wrapperRef = React.createRef<HTMLDivElement>();
-
- this._clearTapTimeout = this._clearTapTimeout.bind(this);
- this._onDoubleTap = this._onDoubleTap.bind(this);
- this._updateLayout = this._updateLayout.bind(this);
- }
-
- /**
- * Implements {@code Component#componentDidUpdate}.
- *
- * @inheritdoc
- */
- componentDidUpdate(prevProps: IProps) {
- const {
- _visibleFilmstrip,
- _isScreenSharing,
- _seeWhatIsBeingShared,
- _largeVideoParticipantId,
- _hideSelfView,
- _localParticipantId } = this.props;
-
- if (prevProps._visibleFilmstrip !== _visibleFilmstrip) {
- this._updateLayout();
- }
-
- if (prevProps._isScreenSharing !== _isScreenSharing && !_isScreenSharing) {
- this.props.dispatch(setSeeWhatIsBeingShared(false));
- }
-
- if (_isScreenSharing && _seeWhatIsBeingShared) {
- VideoLayout.updateLargeVideo(_largeVideoParticipantId, true, true);
- }
-
- if (_largeVideoParticipantId === _localParticipantId
- && prevProps._hideSelfView !== _hideSelfView) {
- VideoLayout.updateLargeVideo(_largeVideoParticipantId, true, false);
- }
- }
-
- /**
- * Implements React's {@link Component#render()}.
- *
- * @inheritdoc
- * @returns {React$Element}
- */
- render() {
- const {
- _displayScreenSharingPlaceholder,
- _isChatOpen,
- _noAutoPlayVideo,
- _showDominantSpeakerBadge,
- _whiteboardEnabled
- } = this.props;
- const style = this._getCustomStyles();
- const className = `videocontainer${_isChatOpen ? ' shift-right' : ''}`;
-
- return (
- <div
- className = { className }
- id = 'largeVideoContainer'
- ref = { this._containerRef }
- style = { style }>
- <SharedVideo />
- {_whiteboardEnabled && <Whiteboard />}
- <div id = 'etherpad' />
-
- <Watermarks />
-
- <div
- id = 'dominantSpeaker'
- onTouchEnd = { this._onDoubleTap }>
- <div className = 'dynamic-shadow' />
- <div id = 'dominantSpeakerAvatarContainer' />
- </div>
- <div id = 'remotePresenceMessage' />
- <span id = 'remoteConnectionMessage' />
- <div id = 'largeVideoElementsContainer'>
- <div id = 'largeVideoBackgroundContainer' />
- {/*
- * FIXME: the architecture of elements related to the large
- * video and the naming. The background is not part of
- * largeVideoWrapper because we are controlling the size of
- * the video through largeVideoWrapper. That's why we need
- * another container for the background and the
- * largeVideoWrapper in order to hide/show them.
- */}
- <div
- id = 'largeVideoWrapper'
- onTouchEnd = { this._onDoubleTap }
- ref = { this._wrapperRef }
- role = 'figure' >
- { _displayScreenSharingPlaceholder ? <ScreenSharePlaceholder /> : <video
- autoPlay = { !_noAutoPlayVideo }
- id = 'largeVideo'
- muted = { true }
- playsInline = { true } /* for Safari on iOS to work */ /> }
- </div>
- </div>
- { interfaceConfig.DISABLE_TRANSCRIPTION_SUBTITLES
- || <Captions /> }
- {_showDominantSpeakerBadge && <StageParticipantNameLabel />}
- </div>
- );
- }
-
- /**
- * Refreshes the video layout to determine the dimensions of the stage view.
- * If the filmstrip is toggled it adds CSS transition classes and removes them
- * when the transition is done.
- *
- * @returns {void}
- */
- _updateLayout() {
- const { _verticalFilmstripWidth, _resizableFilmstrip } = this.props;
-
- if (_resizableFilmstrip && Number(_verticalFilmstripWidth) >= FILMSTRIP_BREAKPOINT) {
- this._containerRef.current?.classList.add('transition');
- this._wrapperRef.current?.classList.add('transition');
- VideoLayout.refreshLayout();
-
- setTimeout(() => {
- this._containerRef?.current && this._containerRef.current.classList.remove('transition');
- this._wrapperRef?.current && this._wrapperRef.current.classList.remove('transition');
- }, 1000);
- } else {
- VideoLayout.refreshLayout();
- }
- }
-
- /**
- * Clears the '_tappedTimout'.
- *
- * @private
- * @returns {void}
- */
- _clearTapTimeout() {
- clearTimeout(this._tappedTimeout);
- this._tappedTimeout = undefined;
- }
-
- /**
- * Creates the custom styles object.
- *
- * @private
- * @returns {Object}
- */
- _getCustomStyles() {
- const styles: any = {};
- const {
- _customBackgroundColor,
- _customBackgroundImageUrl,
- _verticalFilmstripWidth,
- _verticalViewMaxWidth,
- _visibleFilmstrip
- } = this.props;
-
- styles.backgroundColor = _customBackgroundColor || interfaceConfig.DEFAULT_BACKGROUND;
-
- if (this.props._backgroundAlpha !== undefined) {
- const alphaColor = setColorAlpha(styles.backgroundColor, this.props._backgroundAlpha);
-
- styles.backgroundColor = alphaColor;
- }
-
- if (_customBackgroundImageUrl) {
- styles.backgroundImage = `url(${_customBackgroundImageUrl})`;
- styles.backgroundSize = 'cover';
- }
-
- if (_visibleFilmstrip && Number(_verticalFilmstripWidth) >= FILMSTRIP_BREAKPOINT) {
- styles.width = `calc(100% - ${_verticalViewMaxWidth || 0}px)`;
- }
-
- return styles;
- }
-
- /**
- * Sets view to tile view on double tap.
- *
- * @param {Object} e - The event.
- * @private
- * @returns {void}
- */
- _onDoubleTap(e: React.TouchEvent) {
- e.stopPropagation();
- e.preventDefault();
-
- if (this._tappedTimeout) {
- this._clearTapTimeout();
- this.props.dispatch(setTileView(true));
- } else {
- this._tappedTimeout = window.setTimeout(this._clearTapTimeout, 300);
- }
- }
- }
-
-
- /**
- * Maps (parts of) the Redux state to the associated LargeVideo props.
- *
- * @param {Object} state - The Redux state.
- * @private
- * @returns {IProps}
- */
- function _mapStateToProps(state: IReduxState) {
- const testingConfig = state['features/base/config'].testing;
- const { backgroundColor, backgroundImageUrl } = state['features/dynamic-branding'];
- const { isOpen: isChatOpen } = state['features/chat'];
- const { width: verticalFilmstripWidth, visible } = state['features/filmstrip'];
- const { defaultLocalDisplayName, hideDominantSpeakerBadge } = state['features/base/config'];
- const { seeWhatIsBeingShared } = state['features/large-video'];
- const localParticipantId = getLocalParticipant(state)?.id;
- const largeVideoParticipant = getLargeVideoParticipant(state);
- const videoTrack = getVideoTrackByParticipant(state, largeVideoParticipant);
- const isLocalScreenshareOnLargeVideo = largeVideoParticipant?.id?.includes(localParticipantId ?? '')
- && videoTrack?.videoType === VIDEO_TYPE.DESKTOP;
- const isOnSpot = defaultLocalDisplayName === SPOT_DISPLAY_NAME;
-
- return {
- _backgroundAlpha: state['features/base/config'].backgroundAlpha,
- _customBackgroundColor: backgroundColor,
- _customBackgroundImageUrl: backgroundImageUrl,
- _displayScreenSharingPlaceholder: Boolean(isLocalScreenshareOnLargeVideo && !seeWhatIsBeingShared && !isOnSpot),
- _hideSelfView: getHideSelfView(state),
- _isChatOpen: isChatOpen,
- _isScreenSharing: Boolean(isLocalScreenshareOnLargeVideo),
- _largeVideoParticipantId: largeVideoParticipant?.id ?? '',
- _localParticipantId: localParticipantId ?? '',
- _noAutoPlayVideo: Boolean(testingConfig?.noAutoPlayVideo),
- _resizableFilmstrip: isFilmstripResizable(state),
- _seeWhatIsBeingShared: Boolean(seeWhatIsBeingShared),
- _showDominantSpeakerBadge: !hideDominantSpeakerBadge,
- _verticalFilmstripWidth: verticalFilmstripWidth.current,
- _verticalViewMaxWidth: getVerticalViewMaxWidth(state),
- _visibleFilmstrip: visible,
- _whiteboardEnabled: isWhiteboardEnabled(state)
- };
- }
-
- export default connect(_mapStateToProps)(LargeVideo);
|