Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Improve preview playhead (#270)

Lynxc81b8182c892
diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsx
index da48c1bcf..c4e250f8d 100644
--- a/apps/desktop/src/routes/editor/Player.tsx
+++ b/apps/desktop/src/routes/editor/Player.tsx
@@ -43,6 +43,7 @@ export function Player() {
setDialog,
playbackTime,
setPlaybackTime,
+ previewTime,
playing,
setPlaying,
split,
@@ -117,6 +118,11 @@ export function Player() {
createEventListener(document, "keydown", async (e: KeyboardEvent) => {
if (e.code === "Space" && e.target === document.body) {
e.preventDefault();
+ const time = previewTime();
+ if (!playing() && time !== undefined) {
+ setPlaybackTime(time);
+ await commands.seekTo(videoId, Math.floor(time * FPS));
+ }
await handlePlayPauseClick();
}
});
diff --git a/apps/desktop/src/routes/editor/Timeline.tsx b/apps/desktop/src/routes/editor/Timeline.tsx
index 56285bf75..f8184939a 100644
--- a/apps/desktop/src/routes/editor/Timeline.tsx
+++ b/apps/desktop/src/routes/editor/Timeline.tsx
@@ -43,6 +43,7 @@ export function Timeline() {
history,
split,
setState,
+ playing
} = useEditorContext();
const duration = () => editorInstance.recordingDuration;
@@ -138,7 +139,7 @@ export function Timeline() {
setPreviewTime(undefined);
}}
>
- <Show when={previewTime()}>
+ <Show when={!playing() && previewTime()}>
{(time) => (
<div
class={cx(