Fix failing video position reset
## Issue Maybe related to https://github.com/OdyseeTeam/odysee-frontend/issues/99#issuecomment-1042384649 ## Notes `fileInfo` does not contain `metadata` anymore -- not sure what happened. With zero duration, `videoPlayedEnoughToResetPosition` was never true. But the claim usually contains the duration already, so we can use that. There are some audio/video claims that don't, but those are a minority.
This commit is contained in:
parent
491c934119
commit
c36fd425a7
2 changed files with 7 additions and 2 deletions
|
@ -43,6 +43,7 @@ const select = (state, props) => {
|
||||||
hasCollectionById: Boolean(makeSelectCollectionForId(collectionId)(state)),
|
hasCollectionById: Boolean(makeSelectCollectionForId(collectionId)(state)),
|
||||||
collectionId,
|
collectionId,
|
||||||
position: selectContentPositionForUri(state, uri),
|
position: selectContentPositionForUri(state, uri),
|
||||||
|
audioVideoDuration: claim?.value?.video?.duration || claim?.value?.audio?.duration,
|
||||||
commentsListTitle: selectCommentsListTitleForUri(state, uri),
|
commentsListTitle: selectCommentsListTitleForUri(state, uri),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,7 @@ type Props = {
|
||||||
contentCommentsDisabled: boolean,
|
contentCommentsDisabled: boolean,
|
||||||
isLivestream: boolean,
|
isLivestream: boolean,
|
||||||
position: number,
|
position: number,
|
||||||
|
audioVideoDuration: ?number,
|
||||||
commentsListTitle: string,
|
commentsListTitle: string,
|
||||||
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||||
isPlaying?: boolean,
|
isPlaying?: boolean,
|
||||||
|
@ -68,6 +69,7 @@ export default function FilePage(props: Props) {
|
||||||
collectionId,
|
collectionId,
|
||||||
isLivestream,
|
isLivestream,
|
||||||
position,
|
position,
|
||||||
|
audioVideoDuration,
|
||||||
commentsListTitle,
|
commentsListTitle,
|
||||||
settingsByChannelId,
|
settingsByChannelId,
|
||||||
doFetchCostInfoForUri,
|
doFetchCostInfoForUri,
|
||||||
|
@ -87,13 +89,15 @@ export default function FilePage(props: Props) {
|
||||||
const hasFileInfo = fileInfo !== undefined;
|
const hasFileInfo = fileInfo !== undefined;
|
||||||
const isMarkdown = renderMode === RENDER_MODES.MARKDOWN;
|
const isMarkdown = renderMode === RENDER_MODES.MARKDOWN;
|
||||||
const videoPlayedEnoughToResetPosition = React.useMemo(() => {
|
const videoPlayedEnoughToResetPosition = React.useMemo(() => {
|
||||||
|
// I've never seen 'fileInfo' contain metadata lately, but retaining as historical fallback.
|
||||||
const durationInSecs =
|
const durationInSecs =
|
||||||
fileInfo && fileInfo.metadata && fileInfo.metadata.video ? fileInfo.metadata.video.duration : 0;
|
audioVideoDuration ||
|
||||||
|
(fileInfo && fileInfo.metadata && fileInfo.metadata.video ? fileInfo.metadata.video.duration : 0);
|
||||||
const isVideoTooShort = durationInSecs <= 45;
|
const isVideoTooShort = durationInSecs <= 45;
|
||||||
const almostFinishedPlaying = position / durationInSecs >= VIDEO_ALMOST_FINISHED_THRESHOLD;
|
const almostFinishedPlaying = position / durationInSecs >= VIDEO_ALMOST_FINISHED_THRESHOLD;
|
||||||
|
|
||||||
return durationInSecs ? isVideoTooShort || almostFinishedPlaying : false;
|
return durationInSecs ? isVideoTooShort || almostFinishedPlaying : false;
|
||||||
}, [fileInfo, position]);
|
}, [audioVideoDuration, fileInfo, position]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
// always refresh file info when entering file page to see if we have the file
|
// always refresh file info when entering file page to see if we have the file
|
||||||
|
|
Loading…
Reference in a new issue