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';
|
2020-04-14 01:48:11 +02:00
|
|
|
import { doChangeVolume, doChangeMute, doAnalyticsView } from 'redux/actions/app';
|
2019-08-02 08:28:14 +02:00
|
|
|
import { selectVolume, selectMute } from 'redux/selectors/app';
|
2020-05-15 03:18:54 +02:00
|
|
|
import { savePosition, clearPosition } from 'redux/actions/content';
|
2020-04-30 09:49:52 +02:00
|
|
|
import { makeSelectContentPositionForUri } from 'redux/selectors/content';
|
2019-08-02 08:28:14 +02:00
|
|
|
import VideoViewer from './view';
|
2020-02-04 22:14:08 +01:00
|
|
|
import { withRouter } from 'react-router';
|
2020-04-14 01:48:11 +02:00
|
|
|
import { doClaimEligiblePurchaseRewards } from 'lbryinc';
|
|
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
2019-08-02 08:28:14 +02:00
|
|
|
|
2020-02-04 22:14:08 +01:00
|
|
|
const select = (state, props) => {
|
|
|
|
const { search } = props.location;
|
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
const autoplay = urlParams.get('autoplay');
|
2020-04-30 09:49:52 +02:00
|
|
|
const position = urlParams.get('t') !== null ? urlParams.get('t') : makeSelectContentPositionForUri(props.uri)(state);
|
2020-03-19 21:25:37 +01:00
|
|
|
|
2020-02-04 22:14:08 +01:00
|
|
|
return {
|
2020-04-14 01:48:11 +02:00
|
|
|
autoplayIfEmbedded: Boolean(autoplay),
|
|
|
|
autoplaySetting: Boolean(makeSelectClientSetting(SETTINGS.AUTOPLAY)(state)),
|
2020-02-04 22:14:08 +01:00
|
|
|
volume: selectVolume(state),
|
|
|
|
muted: selectMute(state),
|
2020-03-19 21:25:37 +01:00
|
|
|
position: position,
|
2020-02-04 22:14:08 +01:00
|
|
|
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)),
|
2020-05-15 03:18:54 +02:00
|
|
|
clearPosition: uri => dispatch(clearPosition(uri)),
|
2019-08-02 08:28:14 +02:00
|
|
|
changeMute: muted => dispatch(doChangeMute(muted)),
|
2020-04-14 01:48:11 +02:00
|
|
|
doAnalyticsView: (uri, timeToStart) => dispatch(doAnalyticsView(uri, timeToStart)),
|
|
|
|
claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
|
2019-08-02 08:28:14 +02:00
|
|
|
});
|
|
|
|
|
2020-03-19 21:25:37 +01:00
|
|
|
export default withRouter(connect(select, perform)(VideoViewer));
|