mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-31 09:21:27 +00:00
best 7 lines ever
This commit is contained in:
parent
169ae49b06
commit
ef4d8f5988
2 changed files with 12 additions and 8 deletions
|
@ -3,7 +3,6 @@ import { makeSelectClaimForUri, makeSelectFileInfoForUri, makeSelectThumbnailFor
|
||||||
import { doChangeVolume, doChangeMute } from 'redux/actions/app';
|
import { doChangeVolume, doChangeMute } from 'redux/actions/app';
|
||||||
import { selectVolume, selectMute } from 'redux/selectors/app';
|
import { selectVolume, selectMute } from 'redux/selectors/app';
|
||||||
import { savePosition, doSetPlayingUri } from 'redux/actions/content';
|
import { savePosition, doSetPlayingUri } from 'redux/actions/content';
|
||||||
import { makeSelectContentPositionForUri } from 'redux/selectors/content';
|
|
||||||
import VideoViewer from './view';
|
import VideoViewer from './view';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
|
|
||||||
|
@ -11,11 +10,13 @@ const select = (state, props) => {
|
||||||
const { search } = props.location;
|
const { search } = props.location;
|
||||||
const urlParams = new URLSearchParams(search);
|
const urlParams = new URLSearchParams(search);
|
||||||
const autoplay = urlParams.get('autoplay');
|
const autoplay = urlParams.get('autoplay');
|
||||||
|
const position = urlParams.get('t');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
autoplayParam: autoplay,
|
autoplayParam: autoplay,
|
||||||
volume: selectVolume(state),
|
volume: selectVolume(state),
|
||||||
position: makeSelectContentPositionForUri(props.uri)(state),
|
|
||||||
muted: selectMute(state),
|
muted: selectMute(state),
|
||||||
|
position: position,
|
||||||
hasFileInfo: Boolean(makeSelectFileInfoForUri(props.uri)(state)),
|
hasFileInfo: Boolean(makeSelectFileInfoForUri(props.uri)(state)),
|
||||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
|
@ -29,9 +30,4 @@ const perform = dispatch => ({
|
||||||
setPlayingUri: uri => dispatch(doSetPlayingUri(uri)),
|
setPlayingUri: uri => dispatch(doSetPlayingUri(uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(
|
export default withRouter(connect(select, perform)(VideoViewer));
|
||||||
connect(
|
|
||||||
select,
|
|
||||||
perform
|
|
||||||
)(VideoViewer)
|
|
||||||
);
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ function VideoViewer(props: Props) {
|
||||||
volume,
|
volume,
|
||||||
muted,
|
muted,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
position,
|
||||||
claim,
|
claim,
|
||||||
autoplayParam,
|
autoplayParam,
|
||||||
} = props;
|
} = props;
|
||||||
|
@ -74,6 +75,7 @@ function VideoViewer(props: Props) {
|
||||||
const videoRef = useRef();
|
const videoRef = useRef();
|
||||||
const isAudio = contentType.includes('audio');
|
const isAudio = contentType.includes('audio');
|
||||||
const embedded = useContext(EmbedContext);
|
const embedded = useContext(EmbedContext);
|
||||||
|
|
||||||
if (embedded && !autoplayParam) {
|
if (embedded && !autoplayParam) {
|
||||||
VIDEO_JS_OPTIONS.autoplay = false;
|
VIDEO_JS_OPTIONS.autoplay = false;
|
||||||
}
|
}
|
||||||
|
@ -249,6 +251,12 @@ function VideoViewer(props: Props) {
|
||||||
};
|
};
|
||||||
}, [player]);
|
}, [player]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (player && position) {
|
||||||
|
player.currentTime(position);
|
||||||
|
}
|
||||||
|
}, [player, position]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="file-render__viewer" onContextMenu={stopContextMenu}>
|
<div className="file-render__viewer" onContextMenu={stopContextMenu}>
|
||||||
{!requireRedraw && (
|
{!requireRedraw && (
|
||||||
|
|
Loading…
Add table
Reference in a new issue