pause/resume with segment concat

This commit is contained in:
2026-05-12 00:11:25 +03:00
parent 7a821f54fc
commit 7c3ec87b55
4 changed files with 222 additions and 21 deletions
+41 -4
View File
@@ -9,7 +9,7 @@
type ExportResult,
} from "./api"
type Phase = "idle" | "recording" | "editing" | "exporting" | "done"
type Phase = "idle" | "recording" | "paused" | "editing" | "exporting" | "done"
let { onSettings }: { onSettings: () => void } = $props()
@@ -97,6 +97,27 @@
}
}
async function pauseRec() {
clearTick()
try {
await api.pauseCapture()
phase = "paused"
} catch (e) {
errMsg = String(e)
tick()
}
}
async function resumeRec() {
try {
await api.resumeCapture()
phase = "recording"
tick()
} catch (e) {
errMsg = String(e)
}
}
function minMB(durationSecs: number): number {
const minBytes = Math.max(50_000, durationSecs * 50_000)
return Math.max(0.1, minBytes / 1_048_576)
@@ -140,6 +161,7 @@
<h1>ByteSize</h1>
<p class="sub">
{#if phase === "recording"}recording...
{:else if phase === "paused"}paused
{:else if phase === "editing"}clip ready
{:else if phase === "exporting"}encoding...
{:else if phase === "done"}exported
@@ -165,10 +187,19 @@
a region instead.
{/if}
</p>
{:else if phase === "recording"}
{:else if phase === "recording" || phase === "paused"}
<section class="recording">
<div class="elapsed">{elapsed.toFixed(1)}s</div>
<button class="stop big" onclick={stopRec}>stop</button>
<div class="elapsed" class:paused={phase === "paused"}>
{elapsed.toFixed(1)}s
</div>
<div class="row recording-row">
<button class="stop big" onclick={stopRec}>stop</button>
{#if phase === "recording"}
<button class="big" onclick={pauseRec}>pause</button>
{:else}
<button class="primary big" onclick={resumeRec}>resume</button>
{/if}
</div>
</section>
{:else if phase === "editing" && clip}
<section class="clip">
@@ -336,6 +367,12 @@
font-variant-numeric: tabular-nums;
color: #4a8;
}
.elapsed.paused {
color: #c93;
}
.recording-row {
justify-content: center;
}
button {
font: inherit;
padding: 0.5rem 1rem;
+2
View File
@@ -89,6 +89,8 @@ export const api = {
listen<DownloadProgress>("ffmpeg-progress", (e) => handler(e.payload)),
startCapture: (request: StartCaptureRequest) =>
invoke<void>("start_capture", { request }),
pauseCapture: () => invoke<void>("pause_capture"),
resumeCapture: () => invoke<void>("resume_capture"),
stopCapture: () => invoke<RecordedClip>("stop_capture"),
export: (request: ExportRequest) => invoke<ExportResult>("export", { request }),
revealInExplorer: (path: string) => invoke<void>("reveal_in_explorer", { path }),