Fix exception when screenshare is running

This commit is contained in:
Vitor Mateus De Almeida 2020-06-20 23:24:36 -03:00
parent 2454440a8d
commit ad6ee4fdb0
6 changed files with 74 additions and 18 deletions

View File

@ -1,6 +1,5 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import _ from 'lodash';
import injectNotify from '/imports/ui/components/toast/inject-notify/component'; import injectNotify from '/imports/ui/components/toast/inject-notify/component';
import { Session } from 'meteor/session'; import { Session } from 'meteor/session';

View File

@ -2,6 +2,7 @@ import React, { Component, Fragment } from 'react';
import Storage from '/imports/ui/services/storage/session'; import Storage from '/imports/ui/services/storage/session';
import { Session } from 'meteor/session'; import { Session } from 'meteor/session';
import { withLayoutConsumer } from '/imports/ui/components/layout/context'; import { withLayoutConsumer } from '/imports/ui/components/layout/context';
import { isVideoBroadcasting } from '/imports/ui/components/screenshare/service';
const windowWidth = () => window.innerWidth; const windowWidth = () => window.innerWidth;
const windowHeight = () => window.innerHeight; const windowHeight = () => window.innerHeight;
@ -217,9 +218,20 @@ class LayoutManager extends Component {
defineWebcamPlacement(mediaAreaWidth, mediaAreaHeight, presentationWidth, presentationHeight) { defineWebcamPlacement(mediaAreaWidth, mediaAreaHeight, presentationWidth, presentationHeight) {
const { layoutContextDispatch, layoutContextState } = this.props; const { layoutContextDispatch, layoutContextState } = this.props;
const { autoArrangeLayout } = layoutContextState; const { autoArrangeLayout } = layoutContextState;
const isScreenShare = isVideoBroadcasting();
if (!autoArrangeLayout) return; if (!autoArrangeLayout) return;
if (isScreenShare) {
layoutContextDispatch(
{
type: 'setWebcamsPlacement',
value: 'top',
},
);
return;
}
if ((mediaAreaWidth - presentationWidth) > (mediaAreaHeight - presentationHeight)) { if ((mediaAreaWidth - presentationWidth) > (mediaAreaHeight - presentationHeight)) {
layoutContextDispatch( layoutContextDispatch(
{ {
@ -335,6 +347,8 @@ class LayoutManager extends Component {
const autoArrangeLayout = Storage.getItem('autoArrangeLayout'); const autoArrangeLayout = Storage.getItem('autoArrangeLayout');
const webcamsAreaUserSetsHeight = Storage.getItem('webcamsAreaUserSetsHeight'); const webcamsAreaUserSetsHeight = Storage.getItem('webcamsAreaUserSetsHeight');
const webcamsAreaUserSetsWidth = Storage.getItem('webcamsAreaUserSetsWidth'); const webcamsAreaUserSetsWidth = Storage.getItem('webcamsAreaUserSetsWidth');
const isScreenShare = isVideoBroadcasting();
let webcamsAreaWidth; let webcamsAreaWidth;
let webcamsAreaHeight; let webcamsAreaHeight;
@ -345,6 +359,18 @@ class LayoutManager extends Component {
}; };
} }
if (isScreenShare) {
webcamsAreaWidth = mediaAreaWidth;
webcamsAreaHeight = (mediaAreaHeight - presentationHeight)
< (mediaAreaHeight * WEBCAMSAREA_MIN_PERCENT)
? mediaAreaHeight * WEBCAMSAREA_MIN_PERCENT
: mediaAreaHeight - presentationHeight;
return {
webcamsAreaWidth,
webcamsAreaHeight,
};
}
if (autoArrangeLayout) { if (autoArrangeLayout) {
if (webcamsPlacement === 'left' || webcamsPlacement === 'right') { if (webcamsPlacement === 'left' || webcamsPlacement === 'right') {
webcamsAreaWidth = (mediaAreaWidth - presentationWidth) webcamsAreaWidth = (mediaAreaWidth - presentationWidth)
@ -426,6 +452,23 @@ class LayoutManager extends Component {
}; };
} }
calculatesScreenShareAreaSize(
mediaAreaWidth, mediaAreaHeight, webcamAreaWidth, webcamAreaHeight,
) {
const { layoutContextState } = this.props;
const { numUsersVideo } = layoutContextState;
if (numUsersVideo < 1) {
return {
screenShareAreaWidth: mediaAreaWidth,
screenShareAreaHeight: mediaAreaHeight - 20,
};
}
return {
screenShareAreaWidth: mediaAreaWidth,
screenShareAreaHeight: mediaAreaHeight - webcamAreaHeight - 30,
};
}
calculatesLayout(panelChanged = false) { calculatesLayout(panelChanged = false) {
const { const {
layoutContextState, layoutContextState,
@ -467,6 +510,8 @@ class LayoutManager extends Component {
left: firstPanel.width + secondPanel.width, left: firstPanel.width + secondPanel.width,
}; };
const isScreenShare = isVideoBroadcasting();
const { presentationWidth, presentationHeight } = LayoutManager.calculatesPresentationSize( const { presentationWidth, presentationHeight } = LayoutManager.calculatesPresentationSize(
mediaAreaWidth, mediaAreaHeight, presentationSlideWidth, presentationSlideHeight, mediaAreaWidth, mediaAreaHeight, presentationSlideWidth, presentationSlideHeight,
); );
@ -479,26 +524,36 @@ class LayoutManager extends Component {
mediaAreaWidth, mediaAreaHeight, presentationWidth, presentationHeight, mediaAreaWidth, mediaAreaHeight, presentationWidth, presentationHeight,
); );
const { presentationAreaWidth, presentationAreaHeight } = this.calculatesPresentationAreaSize(
mediaAreaWidth, mediaAreaHeight, webcamsAreaWidth, webcamsAreaHeight,
);
const newWebcamsAreaSize = { const newWebcamsAreaSize = {
width: webcamsAreaWidth, width: webcamsAreaWidth,
height: webcamsAreaHeight, height: webcamsAreaHeight,
}; };
let newPresentationAreaSize; let newPresentationAreaSize;
if (!presentationIsFullscreen) { let newScreenShareAreaSize;
newPresentationAreaSize = {
width: presentationAreaWidth || 0, if (isScreenShare) {
height: presentationAreaHeight || 0, const { screenShareAreaWidth, screenShareAreaHeight } = this.calculatesPresentationAreaSize(
mediaAreaWidth, mediaAreaHeight, webcamsAreaWidth, webcamsAreaHeight,
);
newScreenShareAreaSize = {
width: screenShareAreaWidth,
height: screenShareAreaHeight,
}; };
} else { } else {
newPresentationAreaSize = { const { presentationAreaWidth, presentationAreaHeight } = this.calculatesPresentationAreaSize(
width: windowWidth(), mediaAreaWidth, mediaAreaHeight, webcamsAreaWidth, webcamsAreaHeight,
height: windowHeight(), );
}; if (!presentationIsFullscreen) {
newPresentationAreaSize = {
width: presentationAreaWidth || 0,
height: presentationAreaHeight || 0,
};
} else {
newPresentationAreaSize = {
width: windowWidth(),
height: windowHeight(),
};
}
} }
return { return {
@ -508,6 +563,7 @@ class LayoutManager extends Component {
breakoutRoomSize: newBreakoutRoomSize, breakoutRoomSize: newBreakoutRoomSize,
webcamsAreaSize: newWebcamsAreaSize, webcamsAreaSize: newWebcamsAreaSize,
presentationAreaSize: newPresentationAreaSize, presentationAreaSize: newPresentationAreaSize,
screenShareAreaSize: newScreenShareAreaSize,
}; };
} }

View File

@ -9,7 +9,7 @@ import VideoService from '/imports/ui/components/video-provider/service';
import getFromUserSettings from '/imports/ui/services/users-settings'; import getFromUserSettings from '/imports/ui/services/users-settings';
import { withModalMounter } from '/imports/ui/components/modal/service'; import { withModalMounter } from '/imports/ui/components/modal/service';
import Media from './component'; import Media from './component';
import MediaService, { getSwapLayout, shouldEnableSwapLayout } from './service'; import MediaService, { getSwapLayout, shouldEnableSwapLayout } from '/imports/ui/components/media/service';
import PresentationPodsContainer from '../presentation-pod/container'; import PresentationPodsContainer from '../presentation-pod/container';
import ScreenshareContainer from '../screenshare/container'; import ScreenshareContainer from '../screenshare/container';
import DefaultContent from '../presentation/default-content/component'; import DefaultContent from '../presentation/default-content/component';

View File

@ -4,7 +4,6 @@ import { getVideoUrl } from '/imports/ui/components/external-video-player/servic
import Auth from '/imports/ui/services/auth'; import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users'; import Users from '/imports/api/users';
import Settings from '/imports/ui/services/settings'; import Settings from '/imports/ui/services/settings';
import PollingService from '/imports/ui/components/polling/service';
import getFromUserSettings from '/imports/ui/services/users-settings'; import getFromUserSettings from '/imports/ui/services/users-settings';
const LAYOUT_CONFIG = Meteor.settings.public.layout; const LAYOUT_CONFIG = Meteor.settings.public.layout;

View File

@ -4,7 +4,6 @@ import cx from 'classnames';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Resizable from 're-resizable'; import Resizable from 're-resizable';
import { isMobile, isIPad13 } from 'react-device-detect'; import { isMobile, isIPad13 } from 'react-device-detect';
import _ from 'lodash';
import { withDraggableConsumer } from './context'; import { withDraggableConsumer } from './context';
import VideoProviderContainer from '/imports/ui/components/video-provider/container'; import VideoProviderContainer from '/imports/ui/components/video-provider/container';
import { styles } from '../styles.scss'; import { styles } from '../styles.scss';

View File

@ -170,7 +170,10 @@ class ScreenshareComponent extends React.Component {
<video <video
id="screenshareVideo" id="screenshareVideo"
key="screenshareVideo" key="screenshareVideo"
style={{ maxHeight: '100%', width: '100%' }} style={{
maxHeight: '100%',
width: '100%',
}}
playsInline playsInline
onLoadedData={this.onVideoLoad} onLoadedData={this.onVideoLoad}
ref={(ref) => { this.videoTag = ref; }} ref={(ref) => { this.videoTag = ref; }}