lbry-desktop/src/renderer/component/video/index.js

52 lines
2 KiB
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import { connect } from "react-redux";
2017-11-13 22:02:23 +01:00
import { doChangeVolume } from "redux/actions/app";
import { selectVolume } from "redux/selectors/app";
import { doPlayUri, doSetPlayingUri } from "redux/actions/content";
2017-12-21 00:38:11 +01:00
import { doPlay, doPause, savePosition } from "redux/actions/media";
// import { setVideoPause } from "redux/actions/video";
2017-04-23 11:56:50 +02:00
import {
makeSelectMetadataForUri,
makeSelectContentTypeForUri,
2017-11-13 22:02:23 +01:00
} from "redux/selectors/claims";
2017-05-15 05:50:59 +02:00
import {
makeSelectFileInfoForUri,
makeSelectLoadingForUri,
makeSelectDownloadingForUri,
2017-11-13 22:02:23 +01:00
} from "redux/selectors/file_info";
import { makeSelectCostInfoForUri } from "redux/selectors/cost_info";
import { selectShowNsfw } from "redux/selectors/settings";
2017-12-21 00:38:11 +01:00
// import { selectVideoPause } from "redux/selectors/video";
import {
selectMediaPaused,
makeSelectMediaPositionForUri,
} from "redux/selectors/media";
2017-06-06 23:19:12 +02:00
import Video from "./view";
2017-11-13 22:02:23 +01:00
import { selectPlayingUri } from "redux/selectors/content";
2017-05-15 05:50:59 +02:00
2017-09-08 05:15:05 +02:00
const select = (state, props) => ({
costInfo: makeSelectCostInfoForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
obscureNsfw: !selectShowNsfw(state),
isLoading: makeSelectLoadingForUri(props.uri)(state),
isDownloading: makeSelectDownloadingForUri(props.uri)(state),
playingUri: selectPlayingUri(state),
2017-09-08 05:15:05 +02:00
contentType: makeSelectContentTypeForUri(props.uri)(state),
volume: selectVolume(state),
2017-12-21 00:38:11 +01:00
// videoPause: selectVideoPause(state),
mediaPaused: selectMediaPaused(state),
mediaPosition: makeSelectMediaPositionForUri(props.uri)(state),
2017-09-08 05:15:05 +02:00
});
2017-04-23 11:56:50 +02:00
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
play: uri => dispatch(doPlayUri(uri)),
2017-09-18 04:13:05 +02:00
cancelPlay: () => dispatch(doSetPlayingUri(null)),
changeVolume: volume => dispatch(doChangeVolume(volume)),
2017-12-21 00:38:11 +01:00
// setVideoPause: val => dispatch(setVideoPause(val)),
doPlay: () => dispatch(doPlay()),
doPause: (id, position) => dispatch(doPause(id, position)),
2017-06-06 06:21:55 +02:00
});
2017-04-23 11:56:50 +02:00
2017-09-08 05:15:05 +02:00
export default connect(select, perform)(Video);