2017-06-04 10:40:14 +08:00
|
|
|
import React, { Component } from 'react';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2018-01-31 00:32:37 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2018-03-09 19:20:08 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import { notify } from '/imports/ui/services/notification';
|
2016-05-20 21:46:30 +08:00
|
|
|
import Media from './component';
|
2016-05-28 09:10:34 +08:00
|
|
|
import MediaService from './service';
|
2017-02-17 05:11:46 +08:00
|
|
|
import PresentationAreaContainer from '../presentation/container';
|
2018-02-17 03:18:53 +08:00
|
|
|
import VideoProviderContainer from '../video-provider/container';
|
2017-07-25 03:29:34 +08:00
|
|
|
import ScreenshareContainer from '../screenshare/container';
|
2017-02-14 05:08:10 +08:00
|
|
|
import DefaultContent from '../presentation/default-content/component';
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
const defaultProps = {
|
2018-02-01 19:09:33 +08:00
|
|
|
overlay: null,
|
2018-02-01 19:31:17 +08:00
|
|
|
content: <PresentationAreaContainer />,
|
|
|
|
defaultContent: <DefaultContent />,
|
2016-05-04 04:40:46 +08:00
|
|
|
};
|
|
|
|
|
2018-03-09 19:20:08 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
screenshareStarted: {
|
|
|
|
id: 'app.media.screenshare.start',
|
|
|
|
description: 'toast to show when a screenshare has started',
|
|
|
|
},
|
|
|
|
screenshareEnded: {
|
|
|
|
id: 'app.media.screenshare.end',
|
|
|
|
description: 'toast to show when a screenshare has ended',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
class MediaContainer extends Component {
|
2016-04-29 03:02:51 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2016-05-28 09:10:34 +08:00
|
|
|
const { overlay, content, defaultContent } = this.props;
|
2016-05-04 04:40:46 +08:00
|
|
|
this.state = {
|
2017-06-03 03:25:02 +08:00
|
|
|
overlay,
|
2016-05-31 01:33:35 +08:00
|
|
|
content: this.props.current_presentation ? content : defaultContent,
|
2016-05-04 04:40:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
this.handleToggleLayout = this.handleToggleLayout.bind(this);
|
|
|
|
}
|
2016-05-31 01:33:35 +08:00
|
|
|
|
2016-05-28 09:10:34 +08:00
|
|
|
componentWillReceiveProps(nextProps) {
|
2018-03-09 19:20:08 +08:00
|
|
|
const {
|
|
|
|
isScreensharing,
|
|
|
|
intl,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (isScreensharing !== nextProps.isScreensharing) {
|
|
|
|
if (nextProps.isScreensharing) {
|
|
|
|
notify(intl.formatMessage(intlMessages.screenshareStarted), 'info', 'desktop');
|
|
|
|
} else {
|
|
|
|
notify(intl.formatMessage(intlMessages.screenshareEnded), 'info', 'desktop');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-25 03:29:34 +08:00
|
|
|
if (nextProps.current_presentation !== this.props.current_presentation) {
|
2016-05-31 06:07:02 +08:00
|
|
|
if (nextProps.current_presentation) {
|
2016-05-28 09:10:34 +08:00
|
|
|
this.setState({ content: this.props.content });
|
2016-05-31 06:07:02 +08:00
|
|
|
} else {
|
2016-05-28 09:10:34 +08:00
|
|
|
this.setState({ content: this.props.defaultContent });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
handleToggleLayout() {
|
|
|
|
const { overlay, content } = this.state;
|
2018-02-01 19:09:33 +08:00
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
this.setState({ overlay: content, content: overlay });
|
2016-04-29 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-01-31 00:32:37 +08:00
|
|
|
return <Media {...this.props}>{this.props.children}</Media>;
|
2016-04-29 03:02:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
MediaContainer.defaultProps = defaultProps;
|
|
|
|
|
2018-01-08 12:44:42 +08:00
|
|
|
export default withTracker(() => {
|
2018-02-06 21:33:48 +08:00
|
|
|
const { dataSaving } = Settings;
|
2018-03-21 01:22:11 +08:00
|
|
|
const { viewParticipantsWebcams, viewScreenshare } = dataSaving;
|
2018-01-31 00:32:37 +08:00
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
const data = {};
|
2016-09-15 04:25:31 +08:00
|
|
|
data.currentPresentation = MediaService.getPresentationInfo();
|
|
|
|
|
2017-03-22 05:46:41 +08:00
|
|
|
data.content = <DefaultContent />;
|
|
|
|
|
2016-09-15 04:25:31 +08:00
|
|
|
if (MediaService.shouldShowWhiteboard()) {
|
2017-03-07 03:34:30 +08:00
|
|
|
data.content = <PresentationAreaContainer />;
|
2016-09-15 04:25:31 +08:00
|
|
|
}
|
|
|
|
|
2018-02-06 21:33:48 +08:00
|
|
|
if (MediaService.shouldShowScreenshare() && (viewScreenshare || MediaService.isUserPresenter())) {
|
2017-07-25 03:29:34 +08:00
|
|
|
data.content = <ScreenshareContainer />;
|
2016-09-15 04:25:31 +08:00
|
|
|
}
|
|
|
|
|
2018-04-03 19:40:33 +08:00
|
|
|
if (MediaService.shouldShowOverlay() && viewParticipantsWebcams) {
|
2018-02-17 03:18:53 +08:00
|
|
|
data.overlay = <VideoProviderContainer />;
|
2016-09-15 04:25:31 +08:00
|
|
|
}
|
|
|
|
|
2018-03-09 19:20:08 +08:00
|
|
|
data.isScreensharing = MediaService.isVideoBroadcasting();
|
|
|
|
|
2016-05-28 09:10:34 +08:00
|
|
|
return data;
|
2018-03-09 19:20:08 +08:00
|
|
|
})(injectIntl(MediaContainer));
|