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

100 lines
2.4 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';
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';
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,
2019-11-06 05:42:35 +08:00
webcamPlacement: PropTypes.string,
};
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,
2019-11-06 05:42:35 +08:00
webcamPlacement: 'top',
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();
}
componentWillUpdate() {
window.dispatchEvent(new Event('resize'));
}
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,
webcamPlacement,
} = this.props;
2018-04-10 02:28:54 +08:00
const contentClassName = cx({
[styles.content]: true,
});
const overlayClassName = cx({
[styles.overlay]: true,
[styles.hideOverlay]: hideOverlay,
2019-11-06 05:42:35 +08:00
[styles.floatingOverlay]: (webcamPlacement === 'floating'),
});
const { viewParticipantsWebcams } = Settings.dataSaving;
const showVideo = usersVideo.length > 0 && viewParticipantsWebcams;
const fullHeight = !showVideo || (webcamPlacement === 'floating');
return (
2019-03-01 05:39:57 +08:00
<div
2019-03-05 01:29:40 +08:00
id="container"
2019-11-06 05:42:35 +08:00
className={cx(styles.container)}
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: fullHeight ? '100%' : '80%',
2019-07-30 03:42:11 +08:00
minHeight: '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;