Save media position (#489)
This commit is contained in:
parent
ca6fedd05c
commit
c86fdec8e6
7 changed files with 29 additions and 8 deletions
4
app/package-lock.json
generated
4
app/package-lock.json
generated
|
@ -4060,8 +4060,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lbry-redux": {
|
"lbry-redux": {
|
||||||
"version": "github:lbryio/lbry-redux#b9554f9fbe2c8ecf29d63ed07e5d5d93aeb4d141",
|
"version": "github:lbryio/lbry-redux#29865c07763b3cf75e821b9972ed473b2fdbec61",
|
||||||
"from": "github:lbryio/lbry-redux#old-search",
|
"from": "github:lbryio/lbry-redux#save-media-position",
|
||||||
"requires": {
|
"requires": {
|
||||||
"proxy-polyfill": "0.1.6",
|
"proxy-polyfill": "0.1.6",
|
||||||
"reselect": "^3.0.0",
|
"reselect": "^3.0.0",
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base-64": "^0.1.0",
|
"base-64": "^0.1.0",
|
||||||
"@expo/vector-icons": "^8.1.0",
|
"@expo/vector-icons": "^8.1.0",
|
||||||
"lbry-redux": "lbryio/lbry-redux#old-search",
|
"lbry-redux": "lbryio/lbry-redux#save-media-position",
|
||||||
"lbryinc": "lbryio/lbryinc",
|
"lbryinc": "lbryio/lbryinc",
|
||||||
"lodash": ">=4.17.11",
|
"lodash": ">=4.17.11",
|
||||||
"merge": ">=1.2.1",
|
"merge": ">=1.2.1",
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { SETTINGS } from 'lbry-redux';
|
import { SETTINGS, savePosition } from 'lbry-redux';
|
||||||
import { makeSelectClientSetting } from '../../redux/selectors/settings';
|
import { makeSelectClientSetting } from '../../redux/selectors/settings';
|
||||||
import MediaPlayer from './view';
|
import MediaPlayer from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
|
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, null)(MediaPlayer);
|
const perform = dispatch => ({
|
||||||
|
savePosition: (claimId, outpoint, position) => dispatch(savePosition(claimId, outpoint, position)),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(select, perform)(MediaPlayer);
|
||||||
|
|
|
@ -81,13 +81,22 @@ class MediaPlayer extends React.PureComponent {
|
||||||
this.setState({
|
this.setState({
|
||||||
duration: data.duration
|
duration: data.duration
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { position } = this.props;
|
||||||
|
if (!isNaN(parseFloat(position)) && position > 0) {
|
||||||
|
this.video.seek(position);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.props.onMediaLoaded) {
|
if (this.props.onMediaLoaded) {
|
||||||
this.props.onMediaLoaded();
|
this.props.onMediaLoaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onProgress = (data) => {
|
onProgress = (data) => {
|
||||||
this.setState({ currentTime: data.currentTime });
|
const { savePosition, fileInfo } = this.props;
|
||||||
|
|
||||||
|
|
||||||
|
this.setState({ currentTime: data.currentTime }, () => savePosition(fileInfo.claim_id, fileInfo.outpoint, data.currentTime));
|
||||||
|
|
||||||
if (!this.state.seeking) {
|
if (!this.state.seeking) {
|
||||||
this.setSeekerPosition(this.calculateSeekerPosition());
|
this.setSeekerPosition(this.calculateSeekerPosition());
|
||||||
|
@ -98,6 +107,7 @@ class MediaPlayer extends React.PureComponent {
|
||||||
this.props.onPlaybackStarted();
|
this.props.onPlaybackStarted();
|
||||||
}
|
}
|
||||||
this.setState({ firstPlay: false });
|
this.setState({ firstPlay: false });
|
||||||
|
|
||||||
this.hidePlayerControls();
|
this.hidePlayerControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
Lbry,
|
Lbry,
|
||||||
blacklistReducer,
|
blacklistReducer,
|
||||||
claimsReducer,
|
claimsReducer,
|
||||||
|
contentReducer,
|
||||||
costInfoReducer,
|
costInfoReducer,
|
||||||
fileInfoReducer,
|
fileInfoReducer,
|
||||||
notificationsReducer,
|
notificationsReducer,
|
||||||
|
@ -81,6 +82,7 @@ const reducers = combineReducers({
|
||||||
auth: authReducer,
|
auth: authReducer,
|
||||||
blacklist: blacklistReducer,
|
blacklist: blacklistReducer,
|
||||||
claims: claimsReducer,
|
claims: claimsReducer,
|
||||||
|
content: contentReducer,
|
||||||
costInfo: costInfoReducer,
|
costInfo: costInfoReducer,
|
||||||
drawer: drawerReducer,
|
drawer: drawerReducer,
|
||||||
fileInfo: fileInfoReducer,
|
fileInfo: fileInfoReducer,
|
||||||
|
@ -113,13 +115,14 @@ window.store = store;
|
||||||
|
|
||||||
const compressor = createCompressor();
|
const compressor = createCompressor();
|
||||||
const authFilter = createFilter('auth', ['authToken']);
|
const authFilter = createFilter('auth', ['authToken']);
|
||||||
|
const contentFilter = createFilter('content', ['positions']);
|
||||||
const saveClaimsFilter = createFilter('claims', ['byId', 'claimsByUri']);
|
const saveClaimsFilter = createFilter('claims', ['byId', 'claimsByUri']);
|
||||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
||||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||||
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
||||||
|
|
||||||
const persistOptions = {
|
const persistOptions = {
|
||||||
whitelist: ['auth', 'claims', 'subscriptions', 'settings', 'wallet'],
|
whitelist: ['auth', 'claims', 'content', 'subscriptions', 'settings', 'wallet'],
|
||||||
// Order is important. Needs to be compressed last or other transforms can't
|
// Order is important. Needs to be compressed last or other transforms can't
|
||||||
// read the data
|
// read the data
|
||||||
transforms: [authFilter, saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor],
|
transforms: [authFilter, saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor],
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
makeSelectFileInfoForUri,
|
makeSelectFileInfoForUri,
|
||||||
makeSelectChannelForClaimUri,
|
makeSelectChannelForClaimUri,
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
|
makeSelectContentPositionForUri,
|
||||||
makeSelectContentTypeForUri,
|
makeSelectContentTypeForUri,
|
||||||
makeSelectMetadataForUri,
|
makeSelectMetadataForUri,
|
||||||
selectBalance,
|
selectBalance,
|
||||||
|
@ -34,6 +35,7 @@ const select = (state, props) => {
|
||||||
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
|
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
|
||||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
|
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
|
||||||
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
|
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
|
||||||
|
position: makeSelectContentPositionForUri(selectProps.uri)(state)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -368,6 +368,7 @@ class FilePage extends React.PureComponent {
|
||||||
isResolvingUri,
|
isResolvingUri,
|
||||||
blackListedOutpoints,
|
blackListedOutpoints,
|
||||||
navigation,
|
navigation,
|
||||||
|
position,
|
||||||
purchaseUri
|
purchaseUri
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { uri, autoplay } = navigation.state.params;
|
const { uri, autoplay } = navigation.state.params;
|
||||||
|
@ -536,6 +537,7 @@ class FilePage extends React.PureComponent {
|
||||||
onPlaybackStarted={this.onPlaybackStarted}
|
onPlaybackStarted={this.onPlaybackStarted}
|
||||||
onPlaybackFinished={this.onPlaybackFinished}
|
onPlaybackFinished={this.onPlaybackFinished}
|
||||||
thumbnail={metadata.thumbnail}
|
thumbnail={metadata.thumbnail}
|
||||||
|
position={position}
|
||||||
/>}
|
/>}
|
||||||
|
|
||||||
{showActions &&
|
{showActions &&
|
||||||
|
|
Loading…
Reference in a new issue