diff --git a/src/renderer/component/video/index.js b/src/renderer/component/video/index.js index bec9e46b6..36c92eab9 100644 --- a/src/renderer/component/video/index.js +++ b/src/renderer/component/video/index.js @@ -45,7 +45,8 @@ const perform = dispatch => ({ changeVolume: volume => dispatch(doChangeVolume(volume)), // setVideoPause: val => dispatch(setVideoPause(val)), doPlay: () => dispatch(doPlay()), - doPause: (id, position) => dispatch(doPause(id, position)), + doPause: () => dispatch(doPause()), + savePosition: (id, position) => dispatch(savePosition(id, position)), }); 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 7e436f566..be2497032 100644 --- a/src/renderer/component/video/internal/player.jsx +++ b/src/renderer/component/video/internal/player.jsx @@ -72,10 +72,10 @@ class VideoPlayer extends React.PureComponent { if (mediaElement) { mediaElement.currentTime = position; mediaElement.addEventListener("play", () => this.props.doPlay()); - mediaElement.addEventListener("pause", () => { - console.log("CURRENT TIME:", mediaElement.currentTime); - this.props.doPause(this.props.mediaId, mediaElement.currentTime); - }); + mediaElement.addEventListener("pause", () => this.props.doPause()); + mediaElement.addEventListener("timeupdate", () => + this.props.savePosition(mediaId, mediaElement.currentTime) + ); mediaElement.addEventListener("click", this.togglePlayListener); mediaElement.addEventListener( "loadedmetadata", diff --git a/src/renderer/component/video/view.jsx b/src/renderer/component/video/view.jsx index 9f793b783..96715c990 100644 --- a/src/renderer/component/video/view.jsx +++ b/src/renderer/component/video/view.jsx @@ -58,6 +58,7 @@ class Video extends React.PureComponent { uri, doPlay, doPause, + savePosition, mediaPaused, mediaPosition, } = this.props; @@ -119,6 +120,7 @@ class Video extends React.PureComponent { volume={volume} doPlay={doPlay} doPause={doPause} + savePosition={savePosition} mediaId={mediaId} paused={mediaPaused} position={mediaPosition} diff --git a/src/renderer/redux/actions/media.js b/src/renderer/redux/actions/media.js index 2ee20e3fa..6cdc6815e 100644 --- a/src/renderer/redux/actions/media.js +++ b/src/renderer/redux/actions/media.js @@ -8,18 +8,10 @@ export const doPlay = () => (dispatch: Dispatch) => type: actions.MEDIA_PLAY, }); -export const doPause = (id: String, position: String) => ( - dispatch: Dispatch -) => { - if (id && position) { - dispatch({ - type: actions.MEDIA_POSITION, - id, - position, - }); - } - dispatch({ type: actions.MEDIA_PAUSE }); -}; +export const doPause = () => (dispatch: Dispatch) => + dispatch({ + type: actions.MEDIA_PAUSE, + }); export const savePosition = (id: String, position: String) => ( dispatch: Dispatch