Plays an uploaded audio or video file in the global player. FilePreview and JournalCard call it, so a file plays and pauses the same from a list card, a journal tile and its dump's page.
Returns the artwork of an uploaded file, for its thumbnail and the player: the uploaded thumbnail, or the server's still of a video or scaled-down copy of an image. A bare audio file has none, since the thumbnail endpoint has nothing to serve for it, and shows a placeholder instead.
Checks whether dump is an uploaded file the global player can play.
Returns the playback state of the uploaded file dump and a function that
plays or pauses it. The player's title links to the dump's page.
Returned by usePlayFile to the views that play an uploaded file.
-
active: boolean
True while the file is the player's current item, playing or paused.
-
fileUrl: string
The file's URL, with the viewer's media token, as the player loads it.
-
playing: boolean
True while the file is playing.
-
toggle: () => void
Plays the file from the start, or pauses and resumes it once it is the player's current item, so a second click doesn't restart it.
Usage
import * as mod from "src/hooks/player/usePlayFile.ts";