bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/media/component.jsx

129 lines
3.7 KiB
React
Raw Normal View History

import React, { Component } from 'react';
import PropTypes from 'prop-types';
2018-04-10 02:28:54 +08:00
import cx from 'classnames';
import Settings from '/imports/ui/services/settings';
import { isMobile, isIPad13 } from 'react-device-detect';
2019-07-10 07:11:48 +08:00
import WebcamDraggable from './webcam-draggable-overlay/component';
2018-01-08 14:17:18 +08:00
import { styles } from './styles';
import Storage from '../../services/storage/session';
const BROWSER_ISMOBILE = isMobile || isIPad13;
const propTypes = {
children: PropTypes.element.isRequired,
2019-07-24 06:24:31 +08:00
usersVideo: PropTypes.arrayOf(Array),
singleWebcam: PropTypes.bool.isRequired,
2018-04-10 02:28:54 +08:00
hideOverlay: PropTypes.bool,
2019-07-24 06:24:31 +08:00
swapLayout: PropTypes.bool,
disableVideo: PropTypes.bool,
audioModalIsOpen: PropTypes.bool,
2020-04-23 22:07:44 +08:00
layoutContextState: PropTypes.instanceOf(Object).isRequired,
};
2016-05-03 06:42:54 +08:00
2017-10-11 06:08:51 +08:00
const defaultProps = {
2019-07-24 06:24:31 +08:00
usersVideo: [],
2018-04-10 02:28:54 +08:00
hideOverlay: true,
2019-07-24 06:24:31 +08:00
swapLayout: false,
disableVideo: false,
audioModalIsOpen: false,
2017-10-11 06:08:51 +08:00
};
2016-05-03 06:42:54 +08:00
export default class Media extends Component {
constructor(props) {
super(props);
this.refContainer = React.createRef();
}
render() {
const {
2019-04-19 02:48:39 +08:00
swapLayout,
singleWebcam,
2019-04-19 02:48:39 +08:00
hideOverlay,
disableVideo,
children,
audioModalIsOpen,
2019-06-20 04:55:43 +08:00
usersVideo,
2020-04-23 22:07:44 +08:00
layoutContextState,
} = this.props;
2018-04-10 02:28:54 +08:00
2020-04-23 22:07:44 +08:00
const { webcamsPlacement: placement } = layoutContextState;
const placementStorage = Storage.getItem('webcamsPlacement');
const webcamsPlacement = placement || placementStorage;
const contentClassName = cx({
[styles.content]: true,
});
const overlayClassName = cx({
[styles.overlay]: true,
[styles.hideOverlay]: hideOverlay,
2020-04-23 22:07:44 +08:00
[styles.floatingOverlay]: (webcamsPlacement === 'floating'),
});
2019-11-26 00:38:00 +08:00
const containerClassName = cx({
[styles.container]: true,
2020-04-23 22:07:44 +08:00
[styles.containerV]: webcamsPlacement === 'top' || webcamsPlacement === 'bottom' || webcamsPlacement === 'floating',
[styles.containerH]: webcamsPlacement === 'left' || webcamsPlacement === 'right',
2019-11-26 00:38:00 +08:00
});
const { viewParticipantsWebcams } = Settings.dataSaving;
const showVideo = usersVideo.length > 0 && viewParticipantsWebcams;
const fullHeight = !showVideo || (webcamsPlacement === 'floating');
2019-11-26 00:38:00 +08:00
return (
2019-03-01 05:39:57 +08:00
<div
2019-03-05 01:29:40 +08:00
id="container"
2019-11-26 00:38:00 +08:00
className={containerClassName}
ref={this.refContainer}
2019-03-01 05:39:57 +08:00
>
2019-06-20 04:55:43 +08:00
<div
className={!swapLayout ? contentClassName : overlayClassName}
style={{
maxHeight: usersVideo.length > 0
&& (
2020-04-23 22:07:44 +08:00
webcamsPlacement !== 'left'
|| webcamsPlacement !== 'right'
2019-11-26 00:38:00 +08:00
)
&& (
2020-04-23 22:07:44 +08:00
webcamsPlacement === 'top'
|| webcamsPlacement === 'bottom'
2019-11-26 00:38:00 +08:00
)
? '80%'
: '100%',
minHeight: BROWSER_ISMOBILE && window.innerWidth > window.innerHeight ? '50%' : '20%',
maxWidth: usersVideo.length > 0
&& (
2020-04-23 22:07:44 +08:00
webcamsPlacement !== 'top'
|| webcamsPlacement !== 'bottom'
)
&& (
2020-04-23 22:07:44 +08:00
webcamsPlacement === 'left'
|| webcamsPlacement === 'right'
)
? '80%'
: '100%',
2019-11-26 00:38:00 +08:00
minWidth: '20%',
2019-06-20 04:55:43 +08:00
}}
>
{children}
</div>
{showVideo ? (
<WebcamDraggable
refMediaContainer={this.refContainer}
swapLayout={swapLayout}
singleWebcam={singleWebcam}
usersVideoLenght={usersVideo.length}
hideOverlay={hideOverlay}
disableVideo={disableVideo}
audioModalIsOpen={audioModalIsOpen}
usersVideo={usersVideo}
/>
) : null}
2016-05-03 06:42:54 +08:00
</div>
);
}
}
Media.propTypes = propTypes;
2017-10-11 06:08:51 +08:00
Media.defaultProps = defaultProps;