2017-06-04 10:40:14 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-04-10 02:28:54 +08:00
|
|
|
import cx from 'classnames';
|
2021-04-01 01:13:36 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2020-10-21 22:50:06 +08:00
|
|
|
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';
|
2020-01-24 02:09:39 +08:00
|
|
|
import Storage from '../../services/storage/session';
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2021-04-01 01:13:36 +08:00
|
|
|
const { isMobile } = deviceInfo;
|
2020-01-14 04:05:30 +08:00
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
const propTypes = {
|
2018-04-12 02:50:14 +08:00
|
|
|
children: PropTypes.element.isRequired,
|
2019-07-24 06:24:31 +08:00
|
|
|
usersVideo: PropTypes.arrayOf(Array),
|
2019-11-05 03:57:29 +08:00
|
|
|
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-04 04:40:46 +08:00
|
|
|
};
|
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
|
|
|
};
|
|
|
|
|
2018-04-27 23:11:40 +08:00
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
export default class Media extends Component {
|
2019-04-24 04:23:32 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.refContainer = React.createRef();
|
|
|
|
}
|
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
render() {
|
|
|
|
const {
|
2019-04-19 02:48:39 +08:00
|
|
|
swapLayout,
|
2019-11-05 03:57:29 +08:00
|
|
|
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,
|
2021-02-04 00:46:55 +08:00
|
|
|
isMeteorConnected,
|
2018-04-12 02:50:14 +08:00
|
|
|
} = 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;
|
2020-01-24 02:09:39 +08:00
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
const contentClassName = cx({
|
|
|
|
[styles.content]: true,
|
|
|
|
});
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
const overlayClassName = cx({
|
|
|
|
[styles.overlay]: true,
|
|
|
|
[styles.hideOverlay]: hideOverlay,
|
2020-04-23 22:07:44 +08:00
|
|
|
[styles.floatingOverlay]: (webcamsPlacement === 'floating'),
|
2019-11-01 05:11:26 +08:00
|
|
|
});
|
|
|
|
|
2019-11-26 00:38:00 +08:00
|
|
|
const containerClassName = cx({
|
2020-01-24 02:09:39 +08:00
|
|
|
[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
|
|
|
});
|
2020-08-19 03:22:55 +08:00
|
|
|
const { viewParticipantsWebcams } = Settings.dataSaving;
|
2021-02-04 00:46:55 +08:00
|
|
|
const showVideo = usersVideo.length > 0 && viewParticipantsWebcams && isMeteorConnected;
|
2019-11-26 00:38:00 +08:00
|
|
|
|
2016-05-04 04:40:46 +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}
|
2019-04-24 04:23:32 +08:00
|
|
|
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={{
|
2020-01-21 21:57:32 +08:00
|
|
|
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-01-21 21:57:32 +08:00
|
|
|
&& (
|
2020-04-23 22:07:44 +08:00
|
|
|
webcamsPlacement === 'top'
|
|
|
|
|| webcamsPlacement === 'bottom'
|
2019-11-26 00:38:00 +08:00
|
|
|
)
|
2020-01-21 21:57:32 +08:00
|
|
|
? '80%'
|
|
|
|
: '100%',
|
2021-04-01 01:13:36 +08:00
|
|
|
minHeight: isMobile && window.innerWidth > window.innerHeight ? '50%' : '20%',
|
2020-01-21 21:57:32 +08:00
|
|
|
maxWidth: usersVideo.length > 0
|
|
|
|
&& (
|
2020-04-23 22:07:44 +08:00
|
|
|
webcamsPlacement !== 'top'
|
|
|
|
|| webcamsPlacement !== 'bottom'
|
2020-01-21 21:57:32 +08:00
|
|
|
)
|
|
|
|
&& (
|
2020-04-23 22:07:44 +08:00
|
|
|
webcamsPlacement === 'left'
|
|
|
|
|| webcamsPlacement === 'right'
|
2020-01-21 21:57:32 +08:00
|
|
|
)
|
|
|
|
? '80%'
|
|
|
|
: '100%',
|
2019-11-26 00:38:00 +08:00
|
|
|
minWidth: '20%',
|
2019-06-20 04:55:43 +08:00
|
|
|
}}
|
|
|
|
>
|
2018-12-18 05:01:23 +08:00
|
|
|
{children}
|
2018-04-12 02:50:14 +08:00
|
|
|
</div>
|
2020-10-06 19:29:57 +08:00
|
|
|
{showVideo ? (
|
2020-04-30 04:23:29 +08:00
|
|
|
<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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
Media.propTypes = propTypes;
|
2017-10-11 06:08:51 +08:00
|
|
|
Media.defaultProps = defaultProps;
|