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)),
|
||||
collectionId,
|
||||
position: selectContentPositionForUri(state, uri),
|
||||
audioVideoDuration: claim?.value?.video?.duration || claim?.value?.audio?.duration,
|
||||
commentsListTitle: selectCommentsListTitleForUri(state, uri),
|
||||
};
|
||||
};
|
||||
|
|
|
@ -40,6 +40,7 @@ type Props = {
|
|||
contentCommentsDisabled: boolean,
|
||||
isLivestream: boolean,
|
||||
position: number,
|
||||
audioVideoDuration: ?number,
|
||||
commentsListTitle: string,
|
||||
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||
isPlaying?: boolean,
|
||||
|
@ -68,6 +69,7 @@ export default function FilePage(props: Props) {
|
|||
collectionId,
|
||||
isLivestream,
|
||||
position,
|
||||
audioVideoDuration,
|
||||
commentsListTitle,
|
||||
settingsByChannelId,
|
||||
doFetchCostInfoForUri,
|
||||
|
@ -87,13 +89,15 @@ export default function FilePage(props: Props) {
|
|||
const hasFileInfo = fileInfo !== undefined;
|
||||
const isMarkdown = renderMode === RENDER_MODES.MARKDOWN;
|
||||
const videoPlayedEnoughToResetPosition = React.useMemo(() => {
|
||||
// I've never seen 'fileInfo' contain metadata lately, but retaining as historical fallback.
|
||||
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 almostFinishedPlaying = position / durationInSecs >= VIDEO_ALMOST_FINISHED_THRESHOLD;
|
||||
|
||||
return durationInSecs ? isVideoTooShort || almostFinishedPlaying : false;
|
||||
}, [fileInfo, position]);
|
||||
}, [audioVideoDuration, fileInfo, position]);
|
||||
|
||||
React.useEffect(() => {
|
||||
// always refresh file info when entering file page to see if we have the file
|
||||
|
|
Loading…
Reference in a new issue