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

129 lines
3.5 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 { 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,
webcamDraggableState: 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,
webcamDraggableState,
} = this.props;
2018-04-10 02:28:54 +08:00
const { placement } = webcamDraggableState;
const placementStorage = Storage.getItem('webcamPlacement');
const webcamPlacement = placement || placementStorage;
const contentClassName = cx({
[styles.content]: true,
});
const overlayClassName = cx({
[styles.overlay]: true,
[styles.hideOverlay]: hideOverlay,
[styles.floatingOverlay]: (webcamPlacement === 'floating'),
});
2019-11-26 00:38:00 +08:00
const containerClassName = cx({
[styles.container]: true,
[styles.containerV]: webcamPlacement === 'top' || webcamPlacement === 'bottom' || webcamPlacement === 'floating',
[styles.containerH]: webcamPlacement === 'left' || webcamPlacement === 'right',
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
&& (
webcamPlacement !== 'left'
|| webcamPlacement !== 'right'
2019-11-26 00:38:00 +08:00
)
&& (
webcamPlacement === 'top'
|| webcamPlacement === 'bottom'
2019-11-26 00:38:00 +08:00
)
? '80%'
: '100%',
minHeight: BROWSER_ISMOBILE && window.innerWidth > window.innerHeight ? '50%' : '20%',
maxWidth: usersVideo.length > 0
&& (
webcamPlacement !== 'top'
|| webcamPlacement !== 'bottom'
)
&& (
webcamPlacement === 'left'
|| webcamPlacement === 'right'
)
? '80%'
: '100%',
2019-11-26 00:38:00 +08:00
minWidth: '20%',
2019-06-20 04:55:43 +08:00
}}
>
{children}
</div>
{
usersVideo.length > 0
? (
<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;