-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Create snapshot functionality from History view #22639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nrlcode
wants to merge
4
commits into
blakeblackshear:dev
Choose a base branch
from
nrlcode:snapshot-pr-clean
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c5e816f
History: add snapshot support in recording player
nrlcode 84c1836
Snapshot: simplify control wiring and scope cleanup
nrlcode 9e56382
Snapshot: guard against repeated download clicks
nrlcode bef2ecd
Snapshot: move spam-click guard to controls layer
nrlcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,12 +34,14 @@ import { | |
| import { cn } from "@/lib/utils"; | ||
| import { FaCompress, FaExpand } from "react-icons/fa"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { TbCameraDown } from "react-icons/tb"; | ||
|
|
||
| type VideoControls = { | ||
| volume?: boolean; | ||
| seek?: boolean; | ||
| playbackRate?: boolean; | ||
| plusUpload?: boolean; | ||
| snapshot?: boolean; | ||
| fullscreen?: boolean; | ||
| }; | ||
|
|
||
|
|
@@ -48,6 +50,7 @@ const CONTROLS_DEFAULT: VideoControls = { | |
| seek: true, | ||
| playbackRate: true, | ||
| plusUpload: false, | ||
| snapshot: false, | ||
| fullscreen: false, | ||
| }; | ||
| const PLAYBACK_RATE_DEFAULT = isSafari ? [0.5, 1, 2] : [0.5, 1, 2, 4, 8, 16]; | ||
|
|
@@ -71,6 +74,8 @@ type VideoControlsProps = { | |
| onSeek: (diff: number) => void; | ||
| onSetPlaybackRate: (rate: number) => void; | ||
| onUploadFrame?: () => void; | ||
| onSnapshot?: () => void; | ||
| snapshotTitle?: string; | ||
| toggleFullscreen?: () => void; | ||
| containerRef?: React.MutableRefObject<HTMLDivElement | null>; | ||
| }; | ||
|
|
@@ -92,6 +97,8 @@ export default function VideoControls({ | |
| onSeek, | ||
| onSetPlaybackRate, | ||
| onUploadFrame, | ||
| onSnapshot, | ||
| snapshotTitle, | ||
| toggleFullscreen, | ||
| containerRef, | ||
| }: VideoControlsProps) { | ||
|
|
@@ -292,6 +299,17 @@ export default function VideoControls({ | |
| fullscreen={fullscreen} | ||
| /> | ||
| )} | ||
| {features.snapshot && onSnapshot && ( | ||
| <TbCameraDown | ||
| aria-label={snapshotTitle} | ||
| className="size-5 cursor-pointer" | ||
| title={snapshotTitle} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd remove this. None of the other buttons here have a title. |
||
| onClick={(e: React.MouseEvent<SVGElement>) => { | ||
| e.stopPropagation(); | ||
| onSnapshot(); | ||
| }} | ||
| /> | ||
| )} | ||
| {features.fullscreen && toggleFullscreen && ( | ||
| <div className="cursor-pointer" onClick={toggleFullscreen}> | ||
| {fullscreen ? <FaCompress /> : <FaExpand />} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need some kind of loading guard that disables the button while the snapshot is being downloaded (like is done in LiveCameraView's snapshot handler), because a user could spam click the snapshot button, which in most cases will cause the browser to just download a bunch of black frames.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in the guarding features!