mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 12:56:24 -05:00
Resume videos and audio where the user left off; show progress on cards (#791)
* Resume videos and audio where the user left off; show progress on cards Videos and audio resume where the user left off, on the video page and in the file preview, and keep playing. `?t=` starts at an explicit time instead. useFileProgress saves how far the user is through a file: every 15 seconds while it changes, and a final save (a beacon, which survives the page closing) on pause, end, hiding the page, leaving it, or switching files. Each save is also kept in sessionStorage; on open the newer of that and the server's position wins, so coming straight back resumes exactly even if the final save is still in flight. Cards show a progress bar along the bottom of their poster. The dashboard's Recently Viewed Files gains All / Continue; Continue uses the new `in_progress` file search filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Progress review fixes: in_progress totals, latest dashboard request, preview viewed - The in_progress search filter skips the uncounted fast path and is part of the totals cache key, so Continue never reports All's (or the library's) count. - The dashboard's Recently Viewed hook applies only its latest response, and clears the list when switching All/Continue until the new files arrive. - POST /api/files/file returns `viewed`, so a preview can tell a file finished elsewhere from an older position this tab holds. - The progress hook tests restore Blob, fetch and sendBeacon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fbdf5bac82
commit
1ad451cddf
15 changed files with 666 additions and 38 deletions
|
|
@ -8,6 +8,7 @@ import {CbzViewer} from "./CbzViewer";
|
|||
import {StlViewer} from "react-stl-viewer";
|
||||
import {Button, ButtonGroup, Header, Icon, IconButton, MediaGate, Menu, Modal, toast} from "./ui";
|
||||
import {useOneQuery} from "../hooks/customHooks";
|
||||
import {useMediaProgress} from "../hooks/useFileProgress";
|
||||
import {ShareButton} from "./Share";
|
||||
import {AddToPlaylistButton} from "./AddToPlaylist";
|
||||
import {pathDirectory} from "./FileBrowser";
|
||||
|
|
@ -157,6 +158,14 @@ function getImagePreviewModal(previewFile) {
|
|||
</React.Fragment>
|
||||
}
|
||||
|
||||
/** A <video> or <audio> which resumes where the user left off, and saves how far they got. */
|
||||
function PreviewMediaPlayer({as: Element, previewFile, path, style, children}) {
|
||||
const progressHandlers = useMediaProgress(path, previewFile);
|
||||
return <Element controls autoPlay={true} id="player" playsInline={true} style={style} {...progressHandlers}>
|
||||
{children}
|
||||
</Element>
|
||||
}
|
||||
|
||||
function getVideoPreviewModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
|
|
@ -168,14 +177,10 @@ function getVideoPreviewModal(previewFile) {
|
|||
<Modal.Content>
|
||||
<Header as='h5'>{path['path']}</Header>
|
||||
<div className='preview-fit'>
|
||||
<video controls
|
||||
autoPlay={true}
|
||||
id="player"
|
||||
playsInline={true}
|
||||
style={{maxHeight: '100%', maxWidth: '100%'}}
|
||||
>
|
||||
<PreviewMediaPlayer as='video' previewFile={previewFile} path={path}
|
||||
style={{maxHeight: '100%', maxWidth: '100%'}}>
|
||||
<source src={url}/>
|
||||
</video>
|
||||
</PreviewMediaPlayer>
|
||||
</div>
|
||||
</Modal.Content>
|
||||
</React.Fragment>
|
||||
|
|
@ -192,14 +197,10 @@ function getAudioPreviewModal(previewFile) {
|
|||
{name}
|
||||
</Modal.Header>
|
||||
<Modal.Content>
|
||||
<audio controls
|
||||
autoPlay={true}
|
||||
id="player"
|
||||
playsInline={true}
|
||||
style={{width: '90%', maxWidth: '95%'}}
|
||||
>
|
||||
<PreviewMediaPlayer as='audio' previewFile={previewFile} path={path}
|
||||
style={{width: '90%', maxWidth: '95%'}}>
|
||||
<source src={url} type={type}/>
|
||||
</audio>
|
||||
</PreviewMediaPlayer>
|
||||
</Modal.Content>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue