remove video files; save video claimId rather than URI
This commit is contained in:
parent
61b8e8ee71
commit
a8988d9e05
9 changed files with 23 additions and 59 deletions
|
@ -4,7 +4,6 @@ import { doChangeVolume } from "redux/actions/app";
|
|||
import { selectVolume } from "redux/selectors/app";
|
||||
import { doPlayUri, doSetPlayingUri } from "redux/actions/content";
|
||||
import { doPlay, doPause, savePosition } from "redux/actions/media";
|
||||
// import { setVideoPause } from "redux/actions/video";
|
||||
import {
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectContentTypeForUri,
|
||||
|
@ -16,15 +15,16 @@ import {
|
|||
} from "redux/selectors/file_info";
|
||||
import { makeSelectCostInfoForUri } from "redux/selectors/cost_info";
|
||||
import { selectShowNsfw } from "redux/selectors/settings";
|
||||
// import { selectVideoPause } from "redux/selectors/video";
|
||||
import {
|
||||
selectMediaPaused,
|
||||
makeSelectMediaPositionForUri,
|
||||
} from "redux/selectors/media";
|
||||
import Video from "./view";
|
||||
import { selectPlayingUri } from "redux/selectors/content";
|
||||
import { makeSelectClaimForUri } from "redux/selectors/claims";
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
|
@ -34,7 +34,6 @@ const select = (state, props) => ({
|
|||
playingUri: selectPlayingUri(state),
|
||||
contentType: makeSelectContentTypeForUri(props.uri)(state),
|
||||
volume: selectVolume(state),
|
||||
// videoPause: selectVideoPause(state),
|
||||
mediaPaused: selectMediaPaused(state),
|
||||
mediaPosition: makeSelectMediaPositionForUri(props.uri)(state),
|
||||
});
|
||||
|
@ -43,7 +42,6 @@ const perform = dispatch => ({
|
|||
play: uri => dispatch(doPlayUri(uri)),
|
||||
cancelPlay: () => dispatch(doSetPlayingUri(null)),
|
||||
changeVolume: volume => dispatch(doChangeVolume(volume)),
|
||||
// setVideoPause: val => dispatch(setVideoPause(val)),
|
||||
doPlay: () => dispatch(doPlay()),
|
||||
doPause: () => dispatch(doPause()),
|
||||
savePosition: (id, position) => dispatch(savePosition(id, position)),
|
||||
|
|
|
@ -34,10 +34,12 @@ class VideoPlayer extends React.PureComponent {
|
|||
mediaType,
|
||||
changeVolume,
|
||||
volume,
|
||||
mediaId,
|
||||
position,
|
||||
id,
|
||||
} = this.props;
|
||||
|
||||
console.log("position:", position);
|
||||
|
||||
const loadedMetadata = e => {
|
||||
this.setState({ hasMetadata: true, startedPlaying: true });
|
||||
this.refs.media.children[0].play();
|
||||
|
@ -74,7 +76,7 @@ class VideoPlayer extends React.PureComponent {
|
|||
mediaElement.addEventListener("play", () => this.props.doPlay());
|
||||
mediaElement.addEventListener("pause", () => this.props.doPause());
|
||||
mediaElement.addEventListener("timeupdate", () =>
|
||||
this.props.savePosition(mediaId, mediaElement.currentTime)
|
||||
this.props.savePosition(id, mediaElement.currentTime)
|
||||
);
|
||||
mediaElement.addEventListener("click", this.togglePlayListener);
|
||||
mediaElement.addEventListener(
|
||||
|
|
|
@ -55,6 +55,7 @@ class Video extends React.PureComponent {
|
|||
contentType,
|
||||
changeVolume,
|
||||
volume,
|
||||
claim,
|
||||
uri,
|
||||
doPlay,
|
||||
doPause,
|
||||
|
@ -63,6 +64,8 @@ class Video extends React.PureComponent {
|
|||
mediaPosition,
|
||||
} = this.props;
|
||||
|
||||
console.log("mediaPosition:", mediaPosition);
|
||||
|
||||
const isPlaying = playingUri === uri;
|
||||
const isReadyToPlay = fileInfo && fileInfo.written_bytes > 0;
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
|
@ -96,9 +99,6 @@ class Video extends React.PureComponent {
|
|||
}
|
||||
const poster = metadata.thumbnail;
|
||||
|
||||
const mediaId = uri.split("#")[1];
|
||||
console.log("mediaId:", mediaId);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={klasses.join(" ")}
|
||||
|
@ -121,7 +121,7 @@ class Video extends React.PureComponent {
|
|||
doPlay={doPlay}
|
||||
doPause={doPause}
|
||||
savePosition={savePosition}
|
||||
mediaId={mediaId}
|
||||
id={claim.claim_id}
|
||||
paused={mediaPaused}
|
||||
position={mediaPosition}
|
||||
/>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// @flow
|
||||
import * as actions from "constants/action_types";
|
||||
import type { Action, Dispatch } from "redux/reducers/video";
|
||||
import lbry from "lbry";
|
||||
|
||||
export const setVideoPause = (data: boolean) => (dispatch: Dispatch) =>
|
||||
dispatch({
|
||||
type: actions.SET_VIDEO_PAUSE,
|
||||
data,
|
||||
});
|
|
@ -4,7 +4,9 @@ import { handleActions } from "util/redux-utils";
|
|||
|
||||
export type MediaState = {
|
||||
paused: Boolean,
|
||||
positions: Object,
|
||||
positions: {
|
||||
[string]: number,
|
||||
},
|
||||
};
|
||||
|
||||
export type Action = any;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
// @flow
|
||||
import * as actions from "constants/action_types";
|
||||
import { handleActions } from "util/redux-utils";
|
||||
|
||||
export type VideoState = { videoPause: boolean };
|
||||
|
||||
type setVideoPause = {
|
||||
type: actions.SET_VIDEO_PAUSE,
|
||||
data: boolean,
|
||||
};
|
||||
|
||||
export type Action = setVideoPause;
|
||||
export type Dispatch = (action: Action) => any;
|
||||
|
||||
const defaultState = { videoPause: false };
|
||||
|
||||
export default handleActions(
|
||||
{
|
||||
[actions.SET_VIDEO_PAUSE]: (
|
||||
state: VideoState,
|
||||
action: setVideoPause
|
||||
): VideoState => ({ ...state, videoPause: action.data }),
|
||||
},
|
||||
defaultState
|
||||
);
|
|
@ -1,5 +1,6 @@
|
|||
import * as settings from "constants/settings";
|
||||
import { createSelector } from "reselect";
|
||||
import lbryuri from "lbryuri";
|
||||
|
||||
const _selectState = state => state.media || {};
|
||||
|
||||
|
@ -10,6 +11,13 @@ export const selectMediaPaused = createSelector(
|
|||
|
||||
export const makeSelectMediaPositionForUri = uri =>
|
||||
createSelector(_selectState, state => {
|
||||
const id = uri.split("#")[1];
|
||||
return state.positions[id] || null;
|
||||
// console.log("select positions:", state.positions);
|
||||
// const videoId = lbryuri.parse(uri).claimId;
|
||||
// console.log("videoId:", videoId);
|
||||
// const position = state.positions[videoId];
|
||||
// console.log("position:", position);
|
||||
// console.log("positions:", state.positions);
|
||||
const obj = lbryuri.parse(uri);
|
||||
console.log("state.positions:\n", state.positions);
|
||||
return state.positions[obj.claimId] || null;
|
||||
});
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
import * as settings from "constants/settings";
|
||||
import { createSelector } from "reselect";
|
||||
|
||||
const _selectState = state => state.video || {};
|
||||
|
||||
export const selectVideoPause = createSelector(
|
||||
_selectState,
|
||||
state => state.videoPause
|
||||
);
|
|
@ -13,7 +13,6 @@ import userReducer from "redux/reducers/user";
|
|||
import walletReducer from "redux/reducers/wallet";
|
||||
import shapeShiftReducer from "redux/reducers/shape_shift";
|
||||
import subscriptionsReducer from "redux/reducers/subscriptions";
|
||||
import videoReducer from "redux/reducers/video";
|
||||
import mediaReducer from "redux/reducers/media";
|
||||
import { persistStore, autoRehydrate } from "redux-persist";
|
||||
import createCompressor from "redux-persist-transform-compress";
|
||||
|
@ -71,7 +70,6 @@ const reducers = combineReducers({
|
|||
user: userReducer,
|
||||
shapeShift: shapeShiftReducer,
|
||||
subscriptions: subscriptionsReducer,
|
||||
video: videoReducer,
|
||||
media: mediaReducer,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue