2019-08-13 07:35:13 +02:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
|
|
|
import {
|
|
|
|
makeSelectFileInfoForUri,
|
|
|
|
makeSelectThumbnailForUri,
|
|
|
|
makeSelectStreamingUrlForUri,
|
|
|
|
makeSelectMediaTypeForUri,
|
2019-11-26 20:08:34 +01:00
|
|
|
makeSelectContentTypeForUri,
|
2019-08-13 07:35:13 +02:00
|
|
|
makeSelectUriIsStreamable,
|
|
|
|
} from 'lbry-redux';
|
2019-08-19 20:15:54 +02:00
|
|
|
import { makeSelectCostInfoForUri } from 'lbryinc';
|
2019-08-13 07:35:13 +02:00
|
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
2019-12-10 20:45:41 +01:00
|
|
|
import {
|
|
|
|
makeSelectIsPlaying,
|
|
|
|
makeSelectShouldObscurePreview,
|
|
|
|
selectPlayingUri,
|
|
|
|
makeSelectCanAutoplay,
|
|
|
|
} from 'redux/selectors/content';
|
2019-08-13 07:35:13 +02:00
|
|
|
import FileViewer from './view';
|
|
|
|
|
|
|
|
const select = (state, props) => ({
|
|
|
|
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
|
|
|
mediaType: makeSelectMediaTypeForUri(props.uri)(state),
|
2019-11-26 20:08:34 +01:00
|
|
|
contentType: makeSelectContentTypeForUri(props.uri)(state),
|
2019-08-13 07:35:13 +02:00
|
|
|
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
|
|
|
obscurePreview: makeSelectShouldObscurePreview(props.uri)(state),
|
|
|
|
isPlaying: makeSelectIsPlaying(props.uri)(state),
|
|
|
|
playingUri: selectPlayingUri(state),
|
|
|
|
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
|
|
|
isStreamable: makeSelectUriIsStreamable(props.uri)(state),
|
|
|
|
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
|
2019-08-19 20:15:54 +02:00
|
|
|
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
|
2019-08-29 01:33:38 +02:00
|
|
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
2019-12-10 20:45:41 +01:00
|
|
|
isAutoPlayable: makeSelectCanAutoplay(props.uri)(state),
|
2019-08-13 07:35:13 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const perform = dispatch => ({
|
|
|
|
play: uri => {
|
|
|
|
dispatch(doSetPlayingUri(uri));
|
2019-08-13 22:54:57 +02:00
|
|
|
// @if TARGET='app'
|
2019-08-13 07:35:13 +02:00
|
|
|
dispatch(doPlayUri(uri));
|
2019-08-13 22:54:57 +02:00
|
|
|
// @endif
|
2019-08-13 07:35:13 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
select,
|
|
|
|
perform
|
|
|
|
)(FileViewer);
|