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

85 lines
2.6 KiB
React
Raw Normal View History

import React, { Component } from 'react';
import { withTracker } from 'meteor/react-meteor-data';
2018-04-25 00:18:12 +08:00
import SessionStorage from '/imports/ui/services/storage/session';
import Settings from '/imports/ui/services/settings';
import { defineMessages, injectIntl } from 'react-intl';
import { notify } from '/imports/ui/services/notification';
2018-04-10 02:28:54 +08:00
import VideoService from '/imports/ui/components/video-provider/service';
import Media from './component';
2018-04-10 02:48:21 +08:00
import MediaService, { getSwapLayout } from './service';
2017-02-17 05:11:46 +08:00
import PresentationAreaContainer from '../presentation/container';
import ScreenshareContainer from '../screenshare/container';
2017-02-14 05:08:10 +08:00
import DefaultContent from '../presentation/default-content/component';
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 {
componentWillReceiveProps(nextProps) {
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');
}
}
2016-04-29 03:02:51 +08:00
}
render() {
return <Media {...this.props} />;
2016-04-29 03:02:51 +08:00
}
}
export default withTracker(() => {
const { dataSaving } = Settings;
const { viewParticipantsWebcams, viewScreenshare } = dataSaving;
2018-04-25 00:18:12 +08:00
const hidePresentation = SessionStorage.getItem('meta_html5hidepresentation') || false;
2016-09-15 04:25:31 +08:00
2018-04-25 00:18:12 +08:00
const data = {
children: <DefaultContent />,
};
2017-03-22 05:46:41 +08:00
2018-04-25 00:18:12 +08:00
if (MediaService.shouldShowWhiteboard() && !hidePresentation) {
data.currentPresentation = MediaService.getPresentationInfo();
data.children = <PresentationAreaContainer />;
2016-09-15 04:25:31 +08:00
}
if (MediaService.shouldShowScreenshare() && (viewScreenshare || MediaService.isUserPresenter())) {
data.children = <ScreenshareContainer />;
2016-09-15 04:25:31 +08:00
}
2018-04-10 02:28:54 +08:00
const usersVideo = VideoService.getAllUsersVideo();
if (MediaService.shouldShowOverlay() && usersVideo.length) {
2018-04-10 02:28:54 +08:00
data.floatingOverlay = usersVideo.length < 2;
data.hideOverlay = usersVideo.length === 0;
2016-09-15 04:25:31 +08:00
}
data.isScreensharing = MediaService.isVideoBroadcasting();
data.swapLayout = getSwapLayout();
data.disableVideo = !viewParticipantsWebcams;
if (data.swapLayout) {
data.floatingOverlay = true;
2018-04-25 00:18:12 +08:00
if (hidePresentation) {
data.hideOverlay = true;
}
2018-04-10 02:48:21 +08:00
}
return data;
})(injectIntl(MediaContainer));