Fix issue when videoplayer sound was being repeated.
- Do not show overlay when video is paused.
This commit is contained in:
parent
67666229c2
commit
aff0c25a8b
5 changed files with 42 additions and 23 deletions
|
@ -1,14 +1,12 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectShowOverlay } from 'redux/selectors/media';
|
import { selectShowOverlay } from 'redux/selectors/media';
|
||||||
import { doHideOverlay } from 'redux/actions/media';
|
|
||||||
import Overlay from './view';
|
import Overlay from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
showOverlay: selectShowOverlay(state),
|
showOverlay: selectShowOverlay(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
export default connect(
|
||||||
doCloseOverlay: dispatch(doHideOverlay()),
|
select,
|
||||||
});
|
null
|
||||||
|
)(Overlay);
|
||||||
export default connect(select, perform)(Overlay);
|
|
||||||
|
|
|
@ -22,11 +22,6 @@ class VideoPlayer extends React.PureComponent {
|
||||||
this.toggleFullScreenVideo = this.toggleFullScreen.bind(this);
|
this.toggleFullScreenVideo = this.toggleFullScreen.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// componentWillReceiveProps(nextProps) {
|
|
||||||
// const el = this.refs.media.children[0];
|
|
||||||
// if (!this.props.paused && nextProps.paused && !el.paused) el.pause();
|
|
||||||
// }
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const container = this.media;
|
const container = this.media;
|
||||||
const { contentType, changeVolume, volume, position, claim, hiddenControls } = this.props;
|
const { contentType, changeVolume, volume, position, claim, hiddenControls } = this.props;
|
||||||
|
|
|
@ -76,8 +76,8 @@ class Video extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
const { overlayed, doShowOverlay } = this.props;
|
const { overlayed, doShowOverlay, mediaPaused } = this.props;
|
||||||
if (!overlayed) {
|
if (!overlayed && !mediaPaused) {
|
||||||
doShowOverlay();
|
doShowOverlay();
|
||||||
}
|
}
|
||||||
window.removeEventListener('keydown', this.handleKeyDown);
|
window.removeEventListener('keydown', this.handleKeyDown);
|
||||||
|
|
|
@ -2,20 +2,25 @@ import { connect } from 'react-redux';
|
||||||
import { selectPlayingUri } from 'redux/selectors/content';
|
import { selectPlayingUri } from 'redux/selectors/content';
|
||||||
import { doSetPlayingUri } from 'redux/actions/content';
|
import { doSetPlayingUri } from 'redux/actions/content';
|
||||||
import { doNavigate } from 'redux/actions/navigation';
|
import { doNavigate } from 'redux/actions/navigation';
|
||||||
import { doPlay, doPause } from 'redux/actions/media';
|
import { doPlay, doPause, doHideOverlay } from 'redux/actions/media';
|
||||||
import { selectMediaPaused } from 'redux/selectors/media';
|
import { selectMediaPaused, selectShowOverlay } from 'redux/selectors/media';
|
||||||
import VideoOverlay from './view';
|
import VideoOverlay from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
playingUri: selectPlayingUri(state),
|
playingUri: selectPlayingUri(state),
|
||||||
mediaPaused: selectMediaPaused(state),
|
mediaPaused: selectMediaPaused(state),
|
||||||
|
showOverlay: selectShowOverlay(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||||
cancelPlay: () => dispatch(doSetPlayingUri(null)),
|
doCancelPlay: () => dispatch(doSetPlayingUri(null)),
|
||||||
|
doHideOverlay: () => dispatch(doHideOverlay()),
|
||||||
doPlay: () => dispatch(doPlay()),
|
doPlay: () => dispatch(doPlay()),
|
||||||
doPause: () => dispatch(doPause()),
|
doPause: () => dispatch(doPause()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(VideoOverlay);
|
export default connect(
|
||||||
|
select,
|
||||||
|
perform
|
||||||
|
)(VideoOverlay);
|
||||||
|
|
|
@ -7,15 +7,36 @@ import Button from 'component/button';
|
||||||
import * as icons from 'constants/icons';
|
import * as icons from 'constants/icons';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
cancelPlay: () => void,
|
doCancelPlay: () => void,
|
||||||
|
doHideOverlay: () => void,
|
||||||
navigate: (string, ?{}) => void,
|
navigate: (string, ?{}) => void,
|
||||||
doPlay: () => void,
|
doPlay: () => void,
|
||||||
doPause: () => void,
|
doPause: () => void,
|
||||||
playingUri: ?string,
|
playingUri: ?string,
|
||||||
mediaPaused: boolean,
|
mediaPaused: boolean,
|
||||||
|
showOverlay: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class VideoOverlay extends React.Component<Props> {
|
class VideoOverlay extends React.Component<Props> {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
(this: any).closeVideo = this.closeVideo.bind(this);
|
||||||
|
(this: any).returnToMedia = this.returnToMedia.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
closeVideo() {
|
||||||
|
const { doCancelPlay, doHideOverlay } = this.props;
|
||||||
|
doCancelPlay();
|
||||||
|
doHideOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
returnToMedia() {
|
||||||
|
const { navigate, playingUri, doHideOverlay } = this.props;
|
||||||
|
doHideOverlay();
|
||||||
|
navigate('/show', { uri: playingUri });
|
||||||
|
}
|
||||||
|
|
||||||
renderPlayOrPauseButton() {
|
renderPlayOrPauseButton() {
|
||||||
const { mediaPaused, doPause, doPlay } = this.props;
|
const { mediaPaused, doPause, doPlay } = this.props;
|
||||||
if (mediaPaused) {
|
if (mediaPaused) {
|
||||||
|
@ -25,12 +46,12 @@ class VideoOverlay extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { playingUri, cancelPlay, navigate } = this.props;
|
const { playingUri, showOverlay } = this.props;
|
||||||
if (!playingUri) return '';
|
if (!showOverlay) return '';
|
||||||
const returnToMedia = () => navigate('/show', { uri: playingUri });
|
|
||||||
return (
|
return (
|
||||||
<Overlay>
|
<Overlay>
|
||||||
<VideoOverlayHeader uri={playingUri} onClose={cancelPlay} />
|
<VideoOverlayHeader uri={playingUri} onClose={this.closeVideo} />
|
||||||
|
|
||||||
<div className="video__overlay">
|
<div className="video__overlay">
|
||||||
<Video className="content__embedded" uri={playingUri} overlayed hiddenControls />
|
<Video className="content__embedded" uri={playingUri} overlayed hiddenControls />
|
||||||
|
@ -40,7 +61,7 @@ class VideoOverlay extends React.Component<Props> {
|
||||||
noPadding
|
noPadding
|
||||||
button="secondary"
|
button="secondary"
|
||||||
icon={icons.MAXIMIZE}
|
icon={icons.MAXIMIZE}
|
||||||
onClick={() => returnToMedia()}
|
onClick={() => this.returnToMedia()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue