Save media position in video viewer

Closes #2775
This commit is contained in:
Jeffrey Fisher 2020-04-30 00:49:52 -07:00 committed by Sean Yesmunt
parent 8f2e2197f6
commit c1f74aba2e
3 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import { makeSelectClaimForUri, makeSelectFileInfoForUri, makeSelectThumbnailFor
import { doChangeVolume, doChangeMute, doAnalyticsView } from 'redux/actions/app';
import { selectVolume, selectMute } from 'redux/selectors/app';
import { savePosition } from 'redux/actions/content';
import { makeSelectContentPositionForUri } from 'redux/selectors/content';
import VideoViewer from './view';
import { withRouter } from 'react-router';
import { doClaimEligiblePurchaseRewards } from 'lbryinc';
@ -13,7 +14,7 @@ const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);
const autoplay = urlParams.get('autoplay');
const position = urlParams.get('t');
const position = urlParams.get('t') !== null ? urlParams.get('t') : makeSelectContentPositionForUri(props.uri)(state);
return {
autoplayIfEmbedded: Boolean(autoplay),

View file

@ -15,7 +15,7 @@ export type Player = {
volume: (?number) => number,
muted: (?boolean) => boolean,
dispose: () => void,
currentTime: number => void,
currentTime: (?number) => number,
};
type Props = {

View file

@ -31,6 +31,7 @@ type Props = {
autoplayIfEmbedded: boolean,
doAnalyticsView: (string, number) => Promise<any>,
claimRewards: () => void,
savePosition: (string, number) => void,
};
/*
@ -54,6 +55,7 @@ function VideoViewer(props: Props) {
autoplayIfEmbedded,
doAnalyticsView,
claimRewards,
savePosition,
} = props;
const claimId = claim && claim.claim_id;
const isAudio = contentType.includes('audio');
@ -155,6 +157,7 @@ function VideoViewer(props: Props) {
if (position) {
player.currentTime(position);
}
player.on('timeupdate', () => savePosition(uri, player.currentTime()));
},
[uri]
);