2019-08-02 08:28:14 +02:00
|
|
|
import { connect } from 'react-redux';
|
2021-08-25 14:08:30 +02:00
|
|
|
import {
|
|
|
|
makeSelectClaimForUri,
|
|
|
|
makeSelectFileInfoForUri,
|
|
|
|
makeSelectThumbnailForUri,
|
|
|
|
SETTINGS,
|
|
|
|
COLLECTIONS_CONSTS,
|
|
|
|
makeSelectNextUrlForCollectionAndUrl,
|
|
|
|
} from 'lbry-redux';
|
2020-08-07 22:59:20 +02:00
|
|
|
import { doChangeVolume, doChangeMute, doAnalyticsView, doAnalyticsBuffer } from 'redux/actions/app';
|
2019-08-02 08:28:14 +02:00
|
|
|
import { selectVolume, selectMute } from 'redux/selectors/app';
|
2021-08-25 14:08:30 +02:00
|
|
|
import { savePosition, clearPosition, doSetPlayingUri, doPlayUri } from 'redux/actions/content';
|
|
|
|
import {
|
|
|
|
makeSelectContentPositionForUri,
|
|
|
|
selectPlayingUri,
|
|
|
|
makeSelectIsPlayerFloating,
|
|
|
|
} 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-06-15 22:33:03 +02:00
|
|
|
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
|
2021-07-31 05:55:02 +02:00
|
|
|
import { selectDaemonSettings, makeSelectClientSetting, selectHomepageData } from 'redux/selectors/settings';
|
2021-01-14 14:16:04 +01:00
|
|
|
import { toggleVideoTheaterMode, doSetClientSetting } from 'redux/actions/settings';
|
2021-06-29 03:51:04 +02:00
|
|
|
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
|
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');
|
2021-08-10 22:42:50 +02:00
|
|
|
// TODO: eventually this should be received from DB and not local state (https://github.com/lbryio/lbry-desktop/issues/6796)
|
2020-04-30 09:49:52 +02:00
|
|
|
const position = urlParams.get('t') !== null ? urlParams.get('t') : makeSelectContentPositionForUri(props.uri)(state);
|
2021-06-29 03:51:04 +02:00
|
|
|
const userId = selectUser(state) && selectUser(state).id;
|
2021-08-25 14:08:30 +02:00
|
|
|
const playingUri = selectPlayingUri(state);
|
|
|
|
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || (playingUri && playingUri.collectionId);
|
|
|
|
|
|
|
|
let playNextUri;
|
|
|
|
if (collectionId) {
|
|
|
|
playNextUri = makeSelectNextUrlForCollectionAndUrl(collectionId, 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),
|
2021-01-14 14:16:04 +01:00
|
|
|
videoPlaybackRate: makeSelectClientSetting(SETTINGS.VIDEO_PLAYBACK_RATE)(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),
|
2021-04-12 18:43:47 +02:00
|
|
|
homepageData: selectHomepageData(state),
|
|
|
|
authenticated: selectUserVerifiedEmail(state),
|
2021-06-29 03:51:04 +02:00
|
|
|
userId: userId,
|
2021-07-31 05:55:02 +02:00
|
|
|
shareTelemetry: IS_WEB || selectDaemonSettings(state).share_usage_data,
|
2021-08-24 12:36:08 +02:00
|
|
|
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
|
2021-08-25 14:08:30 +02:00
|
|
|
isFloating: makeSelectIsPlayerFloating(props.location)(state),
|
|
|
|
collectionId,
|
|
|
|
playNextUri,
|
2020-02-04 22:14:08 +01:00
|
|
|
};
|
|
|
|
};
|
2019-08-02 08:28:14 +02:00
|
|
|
|
2021-04-12 18:43:47 +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)),
|
2021-04-12 18:43:47 +02:00
|
|
|
clearPosition: (uri) => dispatch(clearPosition(uri)),
|
|
|
|
changeMute: (muted) => dispatch(doChangeMute(muted)),
|
2020-04-14 01:48:11 +02:00
|
|
|
doAnalyticsView: (uri, timeToStart) => dispatch(doAnalyticsView(uri, timeToStart)),
|
2020-08-07 22:59:20 +02:00
|
|
|
doAnalyticsBuffer: (uri, bufferData) => dispatch(doAnalyticsBuffer(uri, bufferData)),
|
2020-04-14 01:48:11 +02:00
|
|
|
claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
|
2021-01-08 16:21:27 +01:00
|
|
|
toggleVideoTheaterMode: () => dispatch(toggleVideoTheaterMode()),
|
2021-04-12 18:43:47 +02:00
|
|
|
setVideoPlaybackRate: (rate) => dispatch(doSetClientSetting(SETTINGS.VIDEO_PLAYBACK_RATE, rate)),
|
2021-08-25 14:08:30 +02:00
|
|
|
doSetPlayingUri: (uri, collectionId) => dispatch(doSetPlayingUri({ uri, collectionId })),
|
|
|
|
doPlayUri: (uri) => dispatch(doPlayUri(uri)),
|
2019-08-02 08:28:14 +02:00
|
|
|
});
|
|
|
|
|
2020-03-19 21:25:37 +01:00
|
|
|
export default withRouter(connect(select, perform)(VideoViewer));
|