lbry-desktop/ui/component/viewers/videoViewer/index.js

34 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-08-02 08:28:14 +02:00
import { connect } from 'react-redux';
2020-01-22 18:19:49 +01:00
import { makeSelectClaimForUri, makeSelectFileInfoForUri, makeSelectThumbnailForUri } from 'lbry-redux';
2019-08-02 08:28:14 +02:00
import { doChangeVolume, doChangeMute } from 'redux/actions/app';
import { selectVolume, selectMute } from 'redux/selectors/app';
2019-09-06 02:26:03 +02:00
import { savePosition, doSetPlayingUri } from 'redux/actions/content';
2019-08-02 08:28:14 +02:00
import VideoViewer from './view';
import { withRouter } from 'react-router';
2019-08-02 08:28:14 +02:00
const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);
const autoplay = urlParams.get('autoplay');
2020-03-19 21:25:37 +01:00
const position = urlParams.get('t');
return {
autoplayParam: autoplay,
volume: selectVolume(state),
muted: selectMute(state),
2020-03-19 21:25:37 +01:00
position: position,
hasFileInfo: Boolean(makeSelectFileInfoForUri(props.uri)(state)),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
};
};
2019-08-02 08:28:14 +02:00
const perform = dispatch => ({
changeVolume: volume => dispatch(doChangeVolume(volume)),
2019-08-13 07:35:13 +02:00
savePosition: (uri, position) => dispatch(savePosition(uri, position)),
2019-08-02 08:28:14 +02:00
changeMute: muted => dispatch(doChangeMute(muted)),
2019-09-06 02:26:03 +02:00
setPlayingUri: uri => dispatch(doSetPlayingUri(uri)),
2019-08-02 08:28:14 +02:00
});
2020-03-19 21:25:37 +01:00
export default withRouter(connect(select, perform)(VideoViewer));