2017-05-24 17:01:46 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-09-01 21:40:05 +00:00
|
|
|
import _ from 'lodash';
|
2017-09-27 21:23:31 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-24 17:01:46 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-08-12 00:27:30 +00:00
|
|
|
import { connect } from 'react-redux';
|
2017-05-24 17:01:46 +00:00
|
|
|
|
2017-10-03 16:30:42 +00:00
|
|
|
import { InviteButton } from '../../invite';
|
2017-07-06 02:07:00 +00:00
|
|
|
import { Toolbox } from '../../toolbox';
|
|
|
|
|
2017-09-01 21:40:05 +00:00
|
|
|
import { setFilmstripHovered } from '../actions';
|
2017-08-29 15:08:16 +00:00
|
|
|
import { shouldRemoteVideosBeVisible } from '../functions';
|
|
|
|
|
2017-05-24 17:01:46 +00:00
|
|
|
/**
|
|
|
|
* Implements a React {@link Component} which represents the filmstrip on
|
|
|
|
* Web/React.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2017-10-24 22:26:56 +00:00
|
|
|
class Filmstrip extends Component<*> {
|
2017-09-01 21:40:05 +00:00
|
|
|
_isHovered: boolean;
|
|
|
|
|
|
|
|
_notifyOfHoveredStateUpdate: Function;
|
|
|
|
|
|
|
|
_onMouseOut: Function;
|
|
|
|
|
|
|
|
_onMouseOver: Function;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@code Filmstrip} component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
2017-07-06 02:07:00 +00:00
|
|
|
static propTypes = {
|
2017-11-10 19:43:40 +00:00
|
|
|
/**
|
|
|
|
* Whether invite button rendering should be skipped,
|
|
|
|
* by default it is. false
|
|
|
|
*/
|
|
|
|
_hideInviteButton: PropTypes.bool,
|
|
|
|
|
2017-09-01 21:40:05 +00:00
|
|
|
/**
|
|
|
|
* Whether or not remote videos are currently being hovered over.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
_hovered: PropTypes.bool,
|
2017-09-01 21:40:05 +00:00
|
|
|
|
2017-08-12 00:27:30 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the remote videos should be visible. Will toggle
|
|
|
|
* a class for hiding the videos.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
_remoteVideosVisible: PropTypes.bool,
|
2017-08-12 00:27:30 +00:00
|
|
|
|
2017-09-01 21:40:05 +00:00
|
|
|
/**
|
|
|
|
* Updates the redux store with filmstrip hover changes.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
dispatch: PropTypes.func,
|
2017-09-01 21:40:05 +00:00
|
|
|
|
2017-07-06 02:07:00 +00:00
|
|
|
/**
|
2017-10-03 16:30:42 +00:00
|
|
|
* Whether or not the conference is in filmstripOnly mode.
|
2017-07-06 02:07:00 +00:00
|
|
|
*/
|
2017-10-03 16:30:42 +00:00
|
|
|
filmstripOnly: PropTypes.bool
|
2017-07-06 02:07:00 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 21:40:05 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new {@code Filmstrip} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Debounce the method for dispatching the new filmstrip handled state
|
|
|
|
// so that it does not get called with each mouse movement event. This
|
|
|
|
// also works around an issue where mouseout and then a mouseover event
|
|
|
|
// is fired when hovering over remote thumbnails, which are not yet in
|
|
|
|
// react.
|
|
|
|
this._notifyOfHoveredStateUpdate
|
|
|
|
= _.debounce(this._notifyOfHoveredStateUpdate, 100);
|
|
|
|
|
|
|
|
// Cache the current hovered state for _updateHoveredState to always
|
|
|
|
// send the last known hovered state.
|
|
|
|
this._isHovered = false;
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onMouseOver = this._onMouseOver.bind(this);
|
|
|
|
this._onMouseOut = this._onMouseOut.bind(this);
|
|
|
|
}
|
|
|
|
|
2017-05-24 17:01:46 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2017-08-12 00:27:30 +00:00
|
|
|
/**
|
|
|
|
* Note: Appending of {@code RemoteVideo} views is handled through
|
|
|
|
* VideoLayout. The views do not get blown away on render() because
|
|
|
|
* ReactDOMComponent is only aware of the given JSX and not new appended
|
|
|
|
* DOM. As such, when updateDOMProperties gets called, only attributes
|
|
|
|
* will get updated without replacing the DOM. If the known DOM gets
|
|
|
|
* modified, then the views will get blown away.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const filmstripClassNames = `filmstrip ${this.props._remoteVideosVisible
|
|
|
|
? '' : 'hide-videos'}`;
|
|
|
|
|
2017-05-24 17:01:46 +00:00
|
|
|
return (
|
2017-08-12 00:27:30 +00:00
|
|
|
<div className = { filmstripClassNames }>
|
2017-10-03 16:30:42 +00:00
|
|
|
{ this.props.filmstripOnly ? <Toolbox /> : null }
|
2017-05-24 17:01:46 +00:00
|
|
|
<div
|
|
|
|
className = 'filmstrip__videos'
|
|
|
|
id = 'remoteVideos'>
|
|
|
|
<div
|
|
|
|
className = 'filmstrip__videos'
|
2017-09-01 21:40:05 +00:00
|
|
|
id = 'filmstripLocalVideo'
|
|
|
|
onMouseOut = { this._onMouseOut }
|
2017-10-03 16:30:42 +00:00
|
|
|
onMouseOver = { this._onMouseOver }>
|
2017-11-10 19:43:40 +00:00
|
|
|
{ this.props.filmstripOnly
|
|
|
|
|| this.props._hideInviteButton
|
|
|
|
? null : <InviteButton /> }
|
2017-11-02 16:22:33 +00:00
|
|
|
<div id = 'filmstripLocalVideoThumbnail' />
|
2017-10-03 16:30:42 +00:00
|
|
|
</div>
|
2017-05-24 17:01:46 +00:00
|
|
|
<div
|
|
|
|
className = 'filmstrip__videos'
|
|
|
|
id = 'filmstripRemoteVideos'>
|
2017-08-12 00:27:30 +00:00
|
|
|
{/**
|
2017-05-24 17:01:46 +00:00
|
|
|
* This extra video container is needed for scrolling
|
|
|
|
* thumbnails in Firefox; otherwise, the flex
|
|
|
|
* thumbnails resize instead of causing overflow.
|
|
|
|
*/}
|
|
|
|
<div
|
|
|
|
className = 'remote-videos-container'
|
2017-09-01 21:40:05 +00:00
|
|
|
id = 'filmstripRemoteVideosContainer'
|
|
|
|
onMouseOut = { this._onMouseOut }
|
|
|
|
onMouseOver = { this._onMouseOver } />
|
2017-05-24 17:01:46 +00:00
|
|
|
</div>
|
|
|
|
<audio
|
|
|
|
id = 'userJoined'
|
|
|
|
preload = 'auto'
|
|
|
|
src = 'sounds/joined.wav' />
|
|
|
|
<audio
|
|
|
|
id = 'userLeft'
|
|
|
|
preload = 'auto'
|
|
|
|
src = 'sounds/left.wav' />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-09-01 21:40:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the current hover state does not match the known hover state in redux,
|
|
|
|
* dispatch an action to update the known hover state in redux.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_notifyOfHoveredStateUpdate() {
|
|
|
|
if (this.props._hovered !== this._isHovered) {
|
|
|
|
this.props.dispatch(setFilmstripHovered(this._isHovered));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the currently known mouseover state and attempt to dispatch an
|
|
|
|
* update of the known hover state in redux.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onMouseOut() {
|
|
|
|
this._isHovered = false;
|
|
|
|
this._notifyOfHoveredStateUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the currently known mouseover state and attempt to dispatch an
|
|
|
|
* update of the known hover state in redux.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onMouseOver() {
|
|
|
|
this._isHovered = true;
|
|
|
|
this._notifyOfHoveredStateUpdate();
|
|
|
|
}
|
2017-05-24 17:01:46 +00:00
|
|
|
}
|
2017-08-12 00:27:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code Filmstrip}'s props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2017-09-01 21:40:05 +00:00
|
|
|
* _hovered: boolean,
|
2017-11-10 19:43:40 +00:00
|
|
|
* _hideInviteButton: boolean,
|
2017-08-12 00:27:30 +00:00
|
|
|
* _remoteVideosVisible: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
2017-09-01 21:40:05 +00:00
|
|
|
_hovered: state['features/filmstrip'].hovered,
|
2017-11-10 19:43:40 +00:00
|
|
|
_hideInviteButton: state['features/base/config'].iAmRecorder,
|
2017-08-29 15:08:16 +00:00
|
|
|
_remoteVideosVisible: shouldRemoteVideosBeVisible(state)
|
2017-08-12 00:27:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(Filmstrip);
|