From ef4d8f5988ee94cc162a9c56ceadbed1941c808e Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 19 Mar 2020 16:25:37 -0400 Subject: [PATCH] best 7 lines ever --- ui/component/viewers/videoViewer/index.js | 12 ++++-------- ui/component/viewers/videoViewer/view.jsx | 8 ++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/component/viewers/videoViewer/index.js b/ui/component/viewers/videoViewer/index.js index 7604402a1..e57c6f43c 100644 --- a/ui/component/viewers/videoViewer/index.js +++ b/ui/component/viewers/videoViewer/index.js @@ -3,7 +3,6 @@ import { makeSelectClaimForUri, makeSelectFileInfoForUri, makeSelectThumbnailFor import { doChangeVolume, doChangeMute } from 'redux/actions/app'; import { selectVolume, selectMute } from 'redux/selectors/app'; import { savePosition, doSetPlayingUri } from 'redux/actions/content'; -import { makeSelectContentPositionForUri } from 'redux/selectors/content'; import VideoViewer from './view'; import { withRouter } from 'react-router'; @@ -11,11 +10,13 @@ const select = (state, props) => { const { search } = props.location; const urlParams = new URLSearchParams(search); const autoplay = urlParams.get('autoplay'); + const position = urlParams.get('t'); + return { autoplayParam: autoplay, volume: selectVolume(state), - position: makeSelectContentPositionForUri(props.uri)(state), muted: selectMute(state), + position: position, hasFileInfo: Boolean(makeSelectFileInfoForUri(props.uri)(state)), thumbnail: makeSelectThumbnailForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state), @@ -29,9 +30,4 @@ const perform = dispatch => ({ setPlayingUri: uri => dispatch(doSetPlayingUri(uri)), }); -export default withRouter( - connect( - select, - perform - )(VideoViewer) -); +export default withRouter(connect(select, perform)(VideoViewer)); diff --git a/ui/component/viewers/videoViewer/view.jsx b/ui/component/viewers/videoViewer/view.jsx index 282914673..f234f2e80 100644 --- a/ui/component/viewers/videoViewer/view.jsx +++ b/ui/component/viewers/videoViewer/view.jsx @@ -67,6 +67,7 @@ function VideoViewer(props: Props) { volume, muted, thumbnail, + position, claim, autoplayParam, } = props; @@ -74,6 +75,7 @@ function VideoViewer(props: Props) { const videoRef = useRef(); const isAudio = contentType.includes('audio'); const embedded = useContext(EmbedContext); + if (embedded && !autoplayParam) { VIDEO_JS_OPTIONS.autoplay = false; } @@ -249,6 +251,12 @@ function VideoViewer(props: Props) { }; }, [player]); + useEffect(() => { + if (player && position) { + player.currentTime(position); + } + }, [player, position]); + return (
{!requireRedraw && (