diff --git a/src/renderer/component/fileDownloadLink/index.js b/src/renderer/component/fileDownloadLink/index.js index 9b1141802..e35dc5b94 100644 --- a/src/renderer/component/fileDownloadLink/index.js +++ b/src/renderer/component/fileDownloadLink/index.js @@ -25,7 +25,7 @@ const perform = dispatch => ({ openInShell: path => dispatch(doOpenFileInShell(path)), purchaseUri: uri => dispatch(doPurchaseUri(uri)), restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)), - videoPause: val => dispatch(setVideoPause(val)), + setVideoPause: val => dispatch(setVideoPause(val)), }); export default connect(select, perform)(FileDownloadLink); diff --git a/src/renderer/component/fileDownloadLink/view.jsx b/src/renderer/component/fileDownloadLink/view.jsx index 68499c273..0619460dd 100644 --- a/src/renderer/component/fileDownloadLink/view.jsx +++ b/src/renderer/component/fileDownloadLink/view.jsx @@ -42,13 +42,12 @@ class FileDownloadLink extends React.PureComponent { purchaseUri, costInfo, loading, - videoPause, + setVideoPause, } = this.props; const openFile = () => { openInShell(fileInfo.download_path); - console.log("FileDownloadLink view"); - videoPause(true); + setVideoPause(true); }; if (loading || downloading) { diff --git a/src/renderer/component/video/index.js b/src/renderer/component/video/index.js index 1b79f8275..04c223f61 100644 --- a/src/renderer/component/video/index.js +++ b/src/renderer/component/video/index.js @@ -35,6 +35,7 @@ const perform = dispatch => ({ play: uri => dispatch(doPlayUri(uri)), cancelPlay: () => dispatch(doSetPlayingUri(null)), changeVolume: volume => dispatch(doChangeVolume(volume)), + setVideoPause: val => dispatch(setVideoPause(val)), }); export default connect(select, perform)(Video); diff --git a/src/renderer/component/video/internal/player.jsx b/src/renderer/component/video/internal/player.jsx index a8b4572c1..42b9b4bf2 100644 --- a/src/renderer/component/video/internal/player.jsx +++ b/src/renderer/component/video/internal/player.jsx @@ -4,9 +4,7 @@ import { Thumbnail } from "component/common"; import player from "render-media"; import fs from "fs"; import LoadingScreen from "./loading-screen"; - -// import { connect } from "react-redux"; -// import { selectVideoPause } from "redux/selectors/video"; +import { setVideoPause } from "../../../redux/actions/video"; class VideoPlayer extends React.PureComponent { static MP3_CONTENT_TYPES = ["audio/mpeg3", "audio/mpeg"]; @@ -23,6 +21,13 @@ class VideoPlayer extends React.PureComponent { this.togglePlayListener = this.togglePlay.bind(this); } + componentWillReceiveProps(nextProps) { + if (nextProps.videoPause) { + this.refs.media.children[0].pause(); + this.props.confirmVideoPause(false); + } + } + componentDidMount() { const container = this.refs.media; const { @@ -160,15 +165,13 @@ class VideoPlayer extends React.PureComponent { } render() { - const { mediaType, poster, videoPause } = this.props; + const { mediaType, poster } = this.props; const { hasMetadata, unplayable } = this.state; const noMetadataMessage = "Waiting for metadata."; const unplayableMessage = "Sorry, looks like we can't play this file."; const needsMetadata = this.playableType(); - console.log("VideoPlayer render; videoPause:", videoPause); - return (
{["audio", "application"].indexOf(mediaType) !== -1 && diff --git a/src/renderer/component/video/view.jsx b/src/renderer/component/video/view.jsx index cb474ea72..355f13dc8 100644 --- a/src/renderer/component/video/view.jsx +++ b/src/renderer/component/video/view.jsx @@ -8,19 +8,11 @@ import NsfwOverlay from "component/nsfwOverlay"; class Video extends React.PureComponent { constructor(props) { super(props); - // console.log("video view props", props); this.state = { showNsfwHelp: false, - // videoPause: false, }; } - componentWillReceiveProps(nextProps) { - console.log("VIDEO COMPONENT WILL RECIEVE NEXTPROPS:", nextProps); - // this.setState({videoPause: nextProps.videoPause}); - // this.refs.media.children[0].pause(); - } - componentWillUnmount() { this.props.cancelPlay(); } @@ -65,9 +57,15 @@ class Video extends React.PureComponent { volume, uri, videoPause, + // setVideoPause, } = this.props; - console.log("VIDEO VIEW videoPause:", videoPause); + // console.log("setVideoPause", setVideoPause); + + const confirmVideoPause = val => { + console.log("this.props.setVideoPause:", this.props.setVideoPause); + this.props.setVideoPause(val); + }; const isPlaying = playingUri === uri; const isReadyToPlay = fileInfo && fileInfo.written_bytes > 0; @@ -103,38 +101,37 @@ class Video extends React.PureComponent { const poster = metadata.thumbnail; return ( -
-

videoPause: {videoPause}

-
- {isPlaying && - (!isReadyToPlay ? ( - - ) : ( - - ))} - {!isPlaying && ( -
- -
- )} - {this.state.showNsfwHelp && } -
+
+ {isPlaying && + (!isReadyToPlay ? ( + + ) : ( + + ))} + {!isPlaying && ( +
+ +
+ )} + {this.state.showNsfwHelp && }
); } diff --git a/src/renderer/redux/selectors/video.js b/src/renderer/redux/selectors/video.js index e79bf8765..65bf1290f 100644 --- a/src/renderer/redux/selectors/video.js +++ b/src/renderer/redux/selectors/video.js @@ -1,7 +1,7 @@ import * as settings from "constants/settings"; import { createSelector } from "reselect"; -const _selectState = state => state.video.videoPause || {}; +const _selectState = state => state.video || {}; export const selectVideoPause = createSelector(_selectState, state => { console.log("VIDEO PAUSE SELECTOR", state);