bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/video-provider/video-dock/component.jsx

117 lines
3.5 KiB
React
Raw Normal View History

import React, { Component } from 'react';
import { styles } from '../styles';
import { defineMessages, injectIntl } from 'react-intl';
import { log } from '/imports/ui/services/api';
import { notify } from '/imports/ui/services/notification';
import { toast } from 'react-toastify';
import { styles as mediaStyles } from '/imports/ui/components/media/styles';
import Toast from '/imports/ui/components/toast/component';
2018-02-14 03:45:03 +08:00
import _ from 'lodash';
import VideoElement from '../video-element/component';
2018-02-15 02:34:00 +08:00
const INITIAL_SHARE_WAIT_TIME = 2000;
const intlMessages = defineMessages({
chromeExtensionError: {
id: 'app.video.chromeExtensionError',
description: 'Error message for Chrome Extension not installed',
},
chromeExtensionErrorLink: {
id: 'app.video.chromeExtensionErrorLink',
description: 'Error message for Chrome Extension not installed',
},
});
class VideoDock extends Component {
2017-09-01 23:26:57 +08:00
constructor(props) {
super(props);
this.state = {};
}
2017-09-01 23:26:57 +08:00
componentDidMount() {
const { users, userId } = this.props;
document.addEventListener('installChromeExtension', this.installChromeExtension.bind(this));
2017-09-20 11:12:10 +08:00
window.addEventListener('resize', this.adjustVideos);
2018-02-07 22:44:11 +08:00
window.addEventListener('orientationchange', this.adjustVideos);
2018-01-29 19:52:07 +08:00
}
componentWillUnmount() {
window.removeEventListener('resize', this.adjustVideos);
2018-02-09 00:32:12 +08:00
window.removeEventListener('orientationchange', this.adjustVideos);
document.removeEventListener('installChromeExtension', this.installChromeExtension.bind(this));
}
componentDidUpdate() {
this.adjustVideos();
}
2017-09-01 23:26:57 +08:00
notifyError(message) {
notify(message, 'error', 'video');
}
installChromeExtension() {
console.log(intlMessages);
const { intl } = this.props;
const CHROME_EXTENSION_LINK = Meteor.settings.public.kurento.chromeExtensionLink;
this.notifyError(<div>
{intl.formatMessage(intlMessages.chromeExtensionError)}{' '}
<a href={CHROME_EXTENSION_LINK} target="_blank">
{intl.formatMessage(intlMessages.chromeExtensionErrorLink)}
</a>
</div>);
}
// TODO
// Find a better place to put this piece of code
2018-01-29 19:52:07 +08:00
adjustVideos() {
setTimeout(() => {
window.adjustVideos('webcamArea', true, mediaStyles.moreThan4Videos, mediaStyles.container, mediaStyles.overlayWrapper, 'presentationAreaData', 'screenshareVideo');
}, 0);
}
2017-09-01 23:26:57 +08:00
getUsersWithActiveStreams() {
const { userId, sharedWebcam } = this.props;
const activeFilter = (user) => {
return user.has_stream || (sharedWebcam && user.userId == userId);
};
return this.props.users.filter(activeFilter);
}
render() {
if (!this.props.socketOpen) {
// TODO: return something when disconnected
2018-03-22 02:33:53 +08:00
return null;
}
const id = this.props.userId;
const sharedWebcam = this.props.sharedWebcam;
return (
2018-03-12 23:29:51 +08:00
<div className={styles.videoDock} id={this.props.sharedWebcam.toString()}>
2018-02-06 03:52:07 +08:00
<div id="webcamArea" className={styles.webcamArea}>
{this.getUsersWithActiveStreams().map(user => (
2018-02-17 03:18:53 +08:00
<VideoElement
shared={id === user.userId && sharedWebcam}
videoId={user.userId}
key={user.userId}
name={user.name}
localCamera={id === user.userId}
onShareWebcam={this.props.onShareWebcam.bind(this)}
onMount={this.props.onStart.bind(this)}
onUnmount={this.props.onStop.bind(this)}
/>
2018-02-17 03:18:53 +08:00
))}
</div>
</div>
);
}
}
export default injectIntl(VideoDock);